commit 65451f9c9dea09c2f34ea0fa62729669660ae395 Author: Jáchym Date: Tue Mar 4 15:23:46 2025 +0100 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a0a433 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +My neovim config diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..44471a6 --- /dev/null +++ b/init.lua @@ -0,0 +1,4 @@ +require("config.options") +require("config.keymaps") +require("config.autocmds") +require("config.lazy") diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua new file mode 100644 index 0000000..9a6995e --- /dev/null +++ b/lua/config/autocmds.lua @@ -0,0 +1,8 @@ +-- Highlight on yank +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..1a8946a --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,8 @@ +-- ESC to stop highlighting search +vim.keymap.set('n', '', 'nohlsearch') + +-- Easier navigration between windows +vim.keymap.set('n', '', '', { desc = 'Move focus to the left window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the right window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) +vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..99d27fc --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,47 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +local lazy = require("lazy") + +lazy.setup({ + spec = { + { import = "plugins" }, + }, + defaults = { + lazy = false, + version = false, + }, + install = { colorscheme = { "moonfly", "wildcharm" } }, + checker = { enabled = true, notify = false }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) + +vim.keymap.set("n", "l", lazy.home) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..9787970 --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,51 @@ +-- Leader +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' +vim.opt.timeoutlen = 300 + +-- Numbers +vim.opt.number = true +vim.opt.relativenumber = true + +-- Mouse +vim.opt.mouse = 'a' + +-- Use system clipboard +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) + +-- Indent +vim.opt.breakindent = true + +-- History +vim.opt.undofile = true +vim.opt.updatetime = 250 + +-- Search +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- UI +vim.opt.signcolumn = 'yes' +vim.opt.scrolloff = 5 +vim.opt.wrap = false + +-- Splits +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Whitespaces +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + +-- Preview substitutions +vim.opt.inccommand = 'split' + +-- Colors +vim.opt.termguicolors = true +vim.opt.cursorline = true + +-- Statusline +vim.opt.laststatus = 3 +vim.opt.showmode = false diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..bc0bba1 --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,5 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = {}, +} diff --git a/lua/plugins/blink-cmp.lua b/lua/plugins/blink-cmp.lua new file mode 100644 index 0000000..68124d8 --- /dev/null +++ b/lua/plugins/blink-cmp.lua @@ -0,0 +1,20 @@ +return { + "saghen/blink.cmp", + dependencies = "rafamadriz/friendly-snippets", + version = "*", + event = "InsertEnter", + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + keymap = { preset = "enter" }, + appearance = { + use_nvim_cmp_as_default = false, + nerd_font_variant = "mono", + }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + fuzzy = { implementation = "prefer_rust_with_warning" }, + }, + opts_extend = { "sources.default" }, +} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 0000000..c066ee5 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,7 @@ +return { + 'akinsho/bufferline.nvim', + version = "*", + dependencies = { 'nvim-tree/nvim-web-devicons' }, + lazy = false, + opts = {}, +} diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 0000000..9092f96 --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,20 @@ +return { + "stevearc/conform.nvim", + keys = { + { + "cf", + function() + require("conform").format({ + async = true, + timeout_ms = 3000, + lsp_format = "fallback", + }) + end, + }, + }, + opts = { + formatters_by_ft = { + lua = { "stylua" }, + }, + }, +} diff --git a/lua/plugins/fzf.lua b/lua/plugins/fzf.lua new file mode 100644 index 0000000..40071c8 --- /dev/null +++ b/lua/plugins/fzf.lua @@ -0,0 +1,20 @@ +return { + "ibhagwan/fzf-lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + event = "VeryLazy", + config = function() + local fzf_lua = require("fzf-lua") + + -- Setup + fzf_lua.setup({}) + + -- Register as the UI for vim.ui.select + fzf_lua.register_ui_select() + + -- Keymaps + vim.keymap.set("n", "ff", fzf_lua.files) + vim.keymap.set("n", "fb", fzf_lua.buffers) + vim.keymap.set("n", "fh", fzf_lua.oldfiles) + vim.keymap.set("n", "fg", fzf_lua.live_grep) + end +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..78e26cf --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,57 @@ +return { + { + "williamboman/mason.nvim", + cmd = "Mason", + keys = { { "cm", "Mason" } }, + opts = { + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, + }, + }, + { + "williamboman/mason-lspconfig.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "williamboman/mason.nvim" }, + opts = { + ensure_installed = { "lua_ls", "gopls" }, + }, + }, + { + "neovim/nvim-lspconfig", + event = { "BufReadPost", "BufNewFile" }, + cmd = { "LspInfo", "LspInstall", "LspUninstall" }, + opts = { + servers = { + lua_ls = {}, + ccls = {}, + gopls = {}, + }, + }, + config = function(_, opts) + local lspconfig = require("lspconfig") + + -- Servers + for server, config in pairs(opts.servers) do + config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities) + lspconfig[server].setup(config) + end + + -- Keybinds + vim.keymap.set("n", "gd", vim.lsp.buf.definition) + vim.keymap.set("n", "cr", vim.lsp.buf.rename) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action) + + -- Signs + local signs = { Error = "󰅚 ", Warn = "󰀪 ", Hint = "󰌶 ", Info = " " } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + end, + }, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..63fd6cb --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,9 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + lazy = false, + opts = { + options = { section_separators = '', component_separators = '' }, + extensions = { "fzf", "lazy", "man", "mason", "nvim-tree"}, + }, +} diff --git a/lua/plugins/moonfly.lua b/lua/plugins/moonfly.lua new file mode 100644 index 0000000..f4eeea7 --- /dev/null +++ b/lua/plugins/moonfly.lua @@ -0,0 +1,12 @@ +return { + "bluz71/vim-moonfly-colors", + name = "moonfly", + lazy = false, + priority = 1000, + init = function() + vim.g.moonflyTransparent = true + end, + config = function() + vim.cmd("colorscheme moonfly") + end +} diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..c02c6cc --- /dev/null +++ b/lua/plugins/nvim-tree.lua @@ -0,0 +1,14 @@ +return { + "nvim-tree/nvim-tree.lua", + version = "*", + dependencies = { "nvim-tree/nvim-web-devicons" }, + event = "VeryLazy", + -- lazy = false, + config = function() + require("nvim-tree").setup({}) + + local api = require("nvim-tree.api") + + vim.keymap.set("n", "e", api.tree.toggle ) + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..3e1a2aa --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,48 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "VeryLazy", + config = function() + local configs = require("nvim-treesitter.configs") + configs.setup({ + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + ensure_installed = { + "bash", + "c", + "diff", + "html", + "javascript", + "jsdoc", + "json", + "jsonc", + "lua", + "luadoc", + "luap", + "markdown", + "markdown_inline", + "printf", + "python", + "query", + "regex", + "toml", + "tsx", + "typescript", + "vim", + "vimdoc", + "xml", + "yaml", + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + scope_incremental = false, + node_decremental = "", + }, + }, + }) + end, +}