From 2e3a540d00c77c8803d9f36229b91053261497d7 Mon Sep 17 00:00:00 2001 From: Or Elimelech Date: Thu, 9 Apr 2026 17:07:00 +0300 Subject: [PATCH 1/4] feat: migrate to nvim 0.12 configs --- nvim/config/init.lua | 64 +++----------- nvim/config/lazy-lock.json | 23 ----- nvim/config/lua/bootstrap.lua | 15 ---- nvim/config/lua/config/autocmds.lua | 15 ++++ nvim/config/lua/config/fzf.lua | 18 ++++ nvim/config/lua/config/git.lua | 9 ++ nvim/config/lua/config/keymaps.lua | 16 ++++ nvim/config/lua/config/lsp.lua | 85 +++++++++++++++++++ nvim/config/lua/config/motion.lua | 9 ++ nvim/config/lua/config/oil.lua | 19 +++++ .../lua/{options.lua => config/opts.lua} | 7 +- nvim/config/lua/config/theme.lua | 39 +++++++++ nvim/config/lua/config/treesitter.lua | 50 +++++++++++ nvim/config/lua/keymaps.lua | 30 ------- nvim/config/lua/plugins/completion.lua | 19 ----- nvim/config/lua/plugins/fzf.lua | 9 -- nvim/config/lua/plugins/git.lua | 13 --- nvim/config/lua/plugins/lsp.lua | 31 ------- nvim/config/lua/plugins/motion.lua | 7 -- nvim/config/lua/plugins/oil.lua | 22 ----- nvim/config/lua/plugins/theme.lua | 38 --------- nvim/config/lua/plugins/treesitter.lua | 40 --------- nvim/config/lua/syntax.lua | 21 ----- nvim/config/nvim-pack-lock.json | 78 +++++++++++++++++ 24 files changed, 351 insertions(+), 326 deletions(-) delete mode 100644 nvim/config/lazy-lock.json delete mode 100644 nvim/config/lua/bootstrap.lua create mode 100644 nvim/config/lua/config/autocmds.lua create mode 100644 nvim/config/lua/config/fzf.lua create mode 100644 nvim/config/lua/config/git.lua create mode 100644 nvim/config/lua/config/keymaps.lua create mode 100644 nvim/config/lua/config/lsp.lua create mode 100644 nvim/config/lua/config/motion.lua create mode 100644 nvim/config/lua/config/oil.lua rename nvim/config/lua/{options.lua => config/opts.lua} (87%) create mode 100644 nvim/config/lua/config/theme.lua create mode 100644 nvim/config/lua/config/treesitter.lua delete mode 100644 nvim/config/lua/keymaps.lua delete mode 100644 nvim/config/lua/plugins/completion.lua delete mode 100644 nvim/config/lua/plugins/fzf.lua delete mode 100644 nvim/config/lua/plugins/git.lua delete mode 100644 nvim/config/lua/plugins/lsp.lua delete mode 100644 nvim/config/lua/plugins/motion.lua delete mode 100644 nvim/config/lua/plugins/oil.lua delete mode 100644 nvim/config/lua/plugins/theme.lua delete mode 100644 nvim/config/lua/plugins/treesitter.lua delete mode 100644 nvim/config/lua/syntax.lua create mode 100644 nvim/config/nvim-pack-lock.json diff --git a/nvim/config/init.lua b/nvim/config/init.lua index c346b02..4fb99b7 100644 --- a/nvim/config/init.lua +++ b/nvim/config/init.lua @@ -1,54 +1,10 @@ -require('bootstrap') -require('options') -require('keymaps') -require('syntax') - -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = {"*.go"}, - callback = function() - -- Format the file - vim.lsp.buf.format({ - async = false, - }) - - -- Organize imports - local params = vim.lsp.util.make_range_params() - params.context = { only = { "source.organizeImports" } } - - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000) - if not result then return end - - for _, res in pairs(result) do - for _, action in pairs(res.result or {}) do - if action.edit then - vim.lsp.util.apply_workspace_edit(action.edit, "utf-16") - else - vim.lsp.buf.execute_command(action.command) - end - end - end - end -}) - -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = {"*.tf"}, - callback = function() - vim.lsp.buf.format() - end -}) - -vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { - pattern = "*.html", - command = "set filetype=html" -}) - -vim.api.nvim_create_autocmd("FileType", { - pattern = {"lua", "ruby", "yaml", "html", "json"}, - callback = function () - vim.opt_local.tabstop = 2 - vim.opt_local.shiftwidth = 2 - vim.opt_local.softtabstop = 2 - vim.opt_local.expandtab = true - vim.opt_local.smartindent = true - end -}) +require('config/opts') +require('config/keymaps') +require('config/theme') +require('config/oil') +require('config/treesitter') +require('config/lsp') +require('config/fzf') +require('config/motion') +require('config/autocmds') +require('config/git') diff --git a/nvim/config/lazy-lock.json b/nvim/config/lazy-lock.json deleted file mode 100644 index 856fba8..0000000 --- a/nvim/config/lazy-lock.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "fzf-lua": { "branch": "main", "commit": "9f0432fdd7825ab163520045831a40b6df82ea28" }, - "git-blame.nvim": { "branch": "main", "commit": "5c536e2d4134d064aa3f41575280bc8a2a0e03d7" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lualine.nvim": { "branch": "master", "commit": "8811f3f3f4dc09d740c67e9ce399e7a541e2e5b2" }, - "mason.nvim": { "branch": "main", "commit": "b03fb0f20bc1d43daf558cda981a2be22e73ac42" }, - "nvim-base16": { "branch": "master", "commit": "38e140f97b3cbefbf2cb29e32fcd098e43e77a42" }, - "nvim-lspconfig": { "branch": "master", "commit": "bedca8b426b2fee0ccac596d167d71bbe971253f" }, - "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, - "nvim-treesitter-context": { "branch": "master", "commit": "b0c45cefe2c8f7b55fc46f34e563bc428ef99636" }, - "nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" }, - "nvim-web-devicons": { "branch": "master", "commit": "95b7a002d5dba1a42eb58f5fac5c565a485eefd0" }, - "oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" }, - "quick-scope": { "branch": "master", "commit": "6cee1d9e0b9ac0fbffeb538d4a5ba9f5628fabbc" }, - "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, - "vim-gurl": { "branch": "master", "commit": "de3e14440fa72e0deaa5cf6c02eef91be706d75a" }, - "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, - "vim-searchindex": { "branch": "master", "commit": "b0788c8213210b3bd23b62847dd5a9ebbe4ad648" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-unimpaired": { "branch": "master", "commit": "db65482581a28e4ccf355be297f1864a4e66985c" } -} diff --git a/nvim/config/lua/bootstrap.lua b/nvim/config/lua/bootstrap.lua deleted file mode 100644 index d983fde..0000000 --- a/nvim/config/lua/bootstrap.lua +++ /dev/null @@ -1,15 +0,0 @@ --- Lazy bootstrap -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.uv.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) - -require("lazy").setup("plugins") diff --git a/nvim/config/lua/config/autocmds.lua b/nvim/config/lua/config/autocmds.lua new file mode 100644 index 0000000..6334507 --- /dev/null +++ b/nvim/config/lua/config/autocmds.lua @@ -0,0 +1,15 @@ +vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { + pattern = "*.html", + command = "set filetype=html" +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = {"lua", "ruby", "yaml", "html", "json"}, + callback = function () + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + vim.opt_local.softtabstop = 2 + vim.opt_local.expandtab = true + vim.opt_local.smartindent = true + end +}) diff --git a/nvim/config/lua/config/fzf.lua b/nvim/config/lua/config/fzf.lua new file mode 100644 index 0000000..a0695e1 --- /dev/null +++ b/nvim/config/lua/config/fzf.lua @@ -0,0 +1,18 @@ +vim.pack.add({ + 'https://github.com/ibhagwan/fzf-lua', + 'https://github.com/nvim-tree/nvim-web-devicons', +}) + +require('fzf-lua').setup({ + fzf_colors = true +}) + +vim.keymap.set('n', 'f', ':FzfLua files', { noremap = true }) +vim.keymap.set('n', 'gf', ':FzfLua git_files', { noremap = true }) +vim.keymap.set('n', 'b', ':FzfLua buffers', { noremap = true }) +vim.keymap.set('n', 'l', ':FzfLua lines', { noremap = true }) +vim.keymap.set('n', 'gs', ':FzfLua git_status', { noremap = true }) +vim.keymap.set('n', 'C', ':FzfLua git_commits', { noremap = true }) +vim.keymap.set('n', 'c', ':FzfLua git_bcommits', { noremap = true }) +vim.keymap.set('n', 'g', ':FzfLua grep_project', { noremap = true }) +vim.keymap.set('n', 'km', ':FzfLua keymaps', { noremap = true }) diff --git a/nvim/config/lua/config/git.lua b/nvim/config/lua/config/git.lua new file mode 100644 index 0000000..c85bed4 --- /dev/null +++ b/nvim/config/lua/config/git.lua @@ -0,0 +1,9 @@ +local gh = function(x) return 'https://github.com/' .. x end + +vim.pack.add({ + gh('tpope/vim-fugitive'), -- Git client + + gh('vitapluvia/vim-gurl'), -- Github URL to clipboard + + gh('f-person/git-blame.nvim'), +}) diff --git a/nvim/config/lua/config/keymaps.lua b/nvim/config/lua/config/keymaps.lua new file mode 100644 index 0000000..32eb3d4 --- /dev/null +++ b/nvim/config/lua/config/keymaps.lua @@ -0,0 +1,16 @@ +local opts = { noremap = true, silent = true } + +-- Global +vim.keymap.set('n', 'h', ':FzfLua helptags', opts) + +-- LSP +vim.keymap.set('n', 'gD', ':FzfLua lsp_declarations', opts) +vim.keymap.set('n', 'gi', ':FzfLua lsp_implementations', opts) +vim.keymap.set('n', 'gr', ':FzfLua lsp_references', opts) +vim.keymap.set('n', 'g0', ':FzfLua lsp_document_symbols', opts) +vim.keymap.set('n', 'gW', ':FzfLua lsp_live_workspace_symbols', opts) +vim.keymap.set('n', 'cl', ':lua vim.lsp.codelens.run()', opts) + +-- nvim-test +vim.keymap.set('n', 'tf', ':TestFile', opts) +vim.keymap.set('n', 'tt', ':TestNearest', opts) diff --git a/nvim/config/lua/config/lsp.lua b/nvim/config/lua/config/lsp.lua new file mode 100644 index 0000000..513c5ef --- /dev/null +++ b/nvim/config/lua/config/lsp.lua @@ -0,0 +1,85 @@ +vim.pack.add({ + 'https://github.com/neovim/nvim-lspconfig', + 'https://github.com/mason-org/mason.nvim', +}) + +require('mason').setup() + +local servers = { + "lua_ls", + "gopls", + "buf_ls", + "jsonls", + "html", + "htmx", + "cssls", + "ts_ls", + "bashls", + "terraformls", + "sqlls", + "zls", + "gleam", + "marksman", +} + +for _, server in ipairs(servers) do + vim.lsp.enable(server) +end + +-- Enable autocomplete +vim.opt.completeopt = 'menu,menuone,noselect,popup' +vim.opt.autocomplete = true + +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("lsp_completion", { clear = true }), + callback = function(args) + local client_id = args.data.client_id + if not client_id then + return + end + + local client = vim.lsp.get_client_by_id(client_id) + if client and client:supports_method("textDocument/completion") then + -- Enable native LSP completion for this client + buffer + vim.lsp.completion.enable(true, client_id, args.buf, { + autotrigger = true, -- auto-show menu as you type (recommended) + -- You can also set { autotrigger = false } and trigger manually with + }) + end + end, +}) + +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = {"*.go"}, + callback = function() + -- Format the file + vim.lsp.buf.format({ + async = false, + }) + + -- Organize imports + local params = vim.lsp.util.make_range_params() + params.context = { only = { "source.organizeImports" } } + + local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000) + if not result then return end + + for _, res in pairs(result) do + for _, action in pairs(res.result or {}) do + if action.edit then + vim.lsp.util.apply_workspace_edit(action.edit, "utf-16") + else + vim.lsp.buf.execute_command(action.command) + end + end + end + end +}) + +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = {"*.tf"}, + callback = function() + vim.lsp.buf.format() + end +}) + diff --git a/nvim/config/lua/config/motion.lua b/nvim/config/lua/config/motion.lua new file mode 100644 index 0000000..e9589f3 --- /dev/null +++ b/nvim/config/lua/config/motion.lua @@ -0,0 +1,9 @@ +local gh = function(x) return 'https://github.com/' .. x end + +vim.pack.add({ + gh('tpope/vim-surround'), + gh('tpope/vim-repeat'), + gh('tpope/vim-unimpaired'), + gh('unblevable/quick-scope'), + gh('google/vim-searchindex'), +}) diff --git a/nvim/config/lua/config/oil.lua b/nvim/config/lua/config/oil.lua new file mode 100644 index 0000000..b94b19f --- /dev/null +++ b/nvim/config/lua/config/oil.lua @@ -0,0 +1,19 @@ +vim.pack.add({ + 'https://github.com/nvim-tree/nvim-web-devicons', + 'https://github.com/stevearc/oil.nvim', +}) + +require('oil').setup({ + float = { + padding = 2, -- Padding around the floating window + max_width = 0.4, -- Max width (90% of screen) + max_height = 0.7, -- Max height (90% of screen) + border = "rounded", -- 'single', 'double', 'shadow', etc. + win_options = { + winblend = 10, -- Transparency + }, + }, +}) + +-- Oil.nvim +vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) diff --git a/nvim/config/lua/options.lua b/nvim/config/lua/config/opts.lua similarity index 87% rename from nvim/config/lua/options.lua rename to nvim/config/lua/config/opts.lua index 0a2da92..69032b6 100644 --- a/nvim/config/lua/options.lua +++ b/nvim/config/lua/config/opts.lua @@ -1,3 +1,6 @@ +-- New UI opt-in +require('vim._core.ui2').enable({}) + vim.opt.timeoutlen = 1000 vim.opt.ttimeoutlen = 0 vim.opt.number = true @@ -12,7 +15,6 @@ vim.opt.cursorline = true vim.opt.cursorcolumn = true vim.opt.autowrite = true vim.opt.shortmess = vim.opt.shortmess + 'c' -vim.opt.completeopt = {'menuone', 'noinsert', 'noselect'} vim.opt.incsearch = true -- show search matches as you type vim.opt.showmatch = true vim.opt.hlsearch = true @@ -32,6 +34,3 @@ vim.opt.spell = false -- Change how diagnostics appear vim.diagnostic.config({ virtual_text = true }) - --- Theme -vim.cmd.colorscheme('base16-gruvbox-dark-hard') diff --git a/nvim/config/lua/config/theme.lua b/nvim/config/lua/config/theme.lua new file mode 100644 index 0000000..0a1253d --- /dev/null +++ b/nvim/config/lua/config/theme.lua @@ -0,0 +1,39 @@ +vim.pack.add({ + 'https://github.com/nvim-tree/nvim-web-devicons', + 'https://github.com/RRethy/nvim-base16', + 'https://github.com/nvim-lualine/lualine.nvim', +}) + +-- Theme +vim.cmd.colorscheme('base16-gruvbox-dark-hard') + +require('lualine').setup({ + sections = { + lualine_b = { + { + "branch", + fmt = function(str) + if #str > 20 then + return str:sub(1, 17) .. "..." + end + return str + end, + }, + "diff", + "diagnostics", + }, + lualine_c = { + { + 'filename', + path = 1, + fmt = function(path) + local parts = vim.split(path, "/") + if #parts > 4 then + return ".../" .. table.concat(parts, "/", #parts - 2) + end + return path + end, + }, + }, + } +}) diff --git a/nvim/config/lua/config/treesitter.lua b/nvim/config/lua/config/treesitter.lua new file mode 100644 index 0000000..ce7b578 --- /dev/null +++ b/nvim/config/lua/config/treesitter.lua @@ -0,0 +1,50 @@ +vim.pack.add({ + { src = 'https://github.com/nvim-treesitter/nvim-treesitter', version = 'main' }, + { src = 'https://github.com/nvim-treesitter/nvim-treesitter-context' }, + { src = 'https://github.com/nvim-treesitter/nvim-treesitter-textobjects', version = 'main' }, +}) + +require('nvim-treesitter').setup({ + incremental_selection = { + enable = true, + }, + + textobjects = { + select = { + enable = true, + + -- Automatically jump forward to textobj, similar to targets.vim + lookahead = true, + + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ["af"] = "@function.outer", + ["if"] = "@function.inner", + } + } + } +}) + +-- Treesitter +local grammer_list = { + 'go', + 'gomod', + 'gosum', + 'javascript', + 'typescript', + 'rust', + 'zig', + 'gleam', + 'elixir', + 'bash', + 'lua', + 'terraform', + 'hcl', +} + +require('nvim-treesitter').install(grammer_list) + +vim.api.nvim_create_autocmd('FileType', { + pattern = grammer_list, + callback = function() vim.treesitter.start() end, +}) diff --git a/nvim/config/lua/keymaps.lua b/nvim/config/lua/keymaps.lua deleted file mode 100644 index 4682378..0000000 --- a/nvim/config/lua/keymaps.lua +++ /dev/null @@ -1,30 +0,0 @@ -local opts = { noremap = true, silent = true } - --- Global -vim.keymap.set('n', 'h', ':FzfLua helptags', opts) - --- LSP -vim.keymap.set('n', 'gD', ':FzfLua lsp_declarations', opts) -vim.keymap.set('n', 'gi', ':FzfLua lsp_implementations', opts) -vim.keymap.set('n', 'gr', ':FzfLua lsp_references', opts) -vim.keymap.set('n', 'g0', ':FzfLua lsp_document_symbols', opts) -vim.keymap.set('n', 'gW', ':FzfLua lsp_live_workspace_symbols', opts) -vim.keymap.set('n', 'cl', ':lua vim.lsp.codelens.run()', opts) - --- nvim-test -vim.keymap.set('n', 'tf', ':TestFile', opts) -vim.keymap.set('n', 'tt', ':TestNearest', opts) - --- FZF -vim.keymap.set('n', 'f', ':FzfLua files', { noremap = true }) -vim.keymap.set('n', 'gf', ':FzfLua git_files', { noremap = true }) -vim.keymap.set('n', 'b', ':FzfLua buffers', { noremap = true }) -vim.keymap.set('n', 'l', ':FzfLua lines', { noremap = true }) -vim.keymap.set('n', 'gs', ':FzfLua git_status', { noremap = true }) -vim.keymap.set('n', 'C', ':FzfLua git_commits', { noremap = true }) -vim.keymap.set('n', 'c', ':FzfLua git_bcommits', { noremap = true }) -vim.keymap.set('n', 'g', ':FzfLua grep_project', { noremap = true }) -vim.keymap.set('n', 'km', ':FzfLua keymaps', { noremap = true }) - --- Oil.nvim -vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) diff --git a/nvim/config/lua/plugins/completion.lua b/nvim/config/lua/plugins/completion.lua deleted file mode 100644 index 572abac..0000000 --- a/nvim/config/lua/plugins/completion.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - { - "saghen/blink.cmp", - dependencies = 'rafamadriz/friendly-snippets', - version = "*", - - opts = { - keymap = { preset = 'default' }, - signature = { enabled = true }, - -- sources = { - -- default = { 'lsp', 'path', 'snippets', 'buffer', 'codecompanion', 'cmdline' }, - -- }, - }, - }, - - -- { - -- "github/copilot.vim", - -- }, -} diff --git a/nvim/config/lua/plugins/fzf.lua b/nvim/config/lua/plugins/fzf.lua deleted file mode 100644 index 9a1205b..0000000 --- a/nvim/config/lua/plugins/fzf.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - { - 'ibhagwan/fzf-lua', - dependencies = { "nvim-tree/nvim-web-devicons" }, - opts = { - fzf_colors = true, - }, - }, -} diff --git a/nvim/config/lua/plugins/git.lua b/nvim/config/lua/plugins/git.lua deleted file mode 100644 index 1c81874..0000000 --- a/nvim/config/lua/plugins/git.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - { - "tpope/vim-fugitive", -- Git client - }, - - { - "vitapluvia/vim-gurl", -- Github URL to clipboard - }, - - { - "f-person/git-blame.nvim", - }, -} diff --git a/nvim/config/lua/plugins/lsp.lua b/nvim/config/lua/plugins/lsp.lua deleted file mode 100644 index 617e695..0000000 --- a/nvim/config/lua/plugins/lsp.lua +++ /dev/null @@ -1,31 +0,0 @@ -return { - { - "neovim/nvim-lspconfig", - config = function() - local servers = { - "gopls", - "buf_ls", - "jsonls", - "html", - "htmx", - "cssls", - "ts_ls", - "bashls", - "terraformls", - "sqlls", - "zls", - "gleam", - "marksman", - } - - for _, server in ipairs(servers) do - vim.lsp.enable(server) - end - end - }, - - { - "mason-org/mason.nvim", -- Manage LSP servers. - opts = {}, - }, -} diff --git a/nvim/config/lua/plugins/motion.lua b/nvim/config/lua/plugins/motion.lua deleted file mode 100644 index 37ab99f..0000000 --- a/nvim/config/lua/plugins/motion.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "tpope/vim-surround", - "tpope/vim-repeat", - "tpope/vim-unimpaired", - "unblevable/quick-scope", - "google/vim-searchindex", -} diff --git a/nvim/config/lua/plugins/oil.lua b/nvim/config/lua/plugins/oil.lua deleted file mode 100644 index 70ad66c..0000000 --- a/nvim/config/lua/plugins/oil.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - { - 'stevearc/oil.nvim', - ---@module 'oil' - ---@type oil.SetupOpts - opts = { - float = { - padding = 2, -- Padding around the floating window - max_width = 0.4, -- Max width (90% of screen) - max_height = 0.7, -- Max height (90% of screen) - border = "rounded", -- 'single', 'double', 'shadow', etc. - win_options = { - winblend = 10, -- Transparency - }, - }, - }, - -- Optional dependencies - -- dependencies = { { "echasnovski/mini.icons", opts = {} } }, - dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons - lazy = false, - }, -} diff --git a/nvim/config/lua/plugins/theme.lua b/nvim/config/lua/plugins/theme.lua deleted file mode 100644 index 3ab19f6..0000000 --- a/nvim/config/lua/plugins/theme.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - "RRethy/nvim-base16", - - { - "nvim-lualine/lualine.nvim", - dependencies = { 'nvim-tree/nvim-web-devicons' }, - opts = { - sections = { - lualine_b = { - { - "branch", - fmt = function(str) - if #str > 20 then - return str:sub(1, 17) .. "..." - end - return str - end, - }, - "diff", - "diagnostics", - }, - lualine_c = { - { - 'filename', - path = 1, - fmt = function(path) - local parts = vim.split(path, "/") - if #parts > 4 then - return ".../" .. table.concat(parts, "/", #parts - 2) - end - return path - end, - }, - }, - }, - }, - }, -} diff --git a/nvim/config/lua/plugins/treesitter.lua b/nvim/config/lua/plugins/treesitter.lua deleted file mode 100644 index 51e2081..0000000 --- a/nvim/config/lua/plugins/treesitter.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - branch = "main", - lazy = false, - opts = { - incremental_selection = { - enable = true, - }, - - textobjects = { - select = { - enable = true, - - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - }, - }, - }, - } - }, - - { - "nvim-treesitter/nvim-treesitter-context", -- Show the context you are in. - -- dependencies = { "nvim-treesitter/nvim-treesitter" }, - opts = {}, - }, - - { - "nvim-treesitter/nvim-treesitter-textobjects", - branch = "main", - -- dependencies = { "nvim-treesitter/nvim-treesitter" }, - }, -} diff --git a/nvim/config/lua/syntax.lua b/nvim/config/lua/syntax.lua deleted file mode 100644 index c2d2f3f..0000000 --- a/nvim/config/lua/syntax.lua +++ /dev/null @@ -1,21 +0,0 @@ -local grammer_list = { - 'go', - 'gomod', - 'gosum', - 'javascript', - 'typescript', - 'rust', - 'zig', - 'gleam', - 'elixir', - 'bash', - 'lua', -} - -require('nvim-treesitter').install(grammer_list) - -vim.api.nvim_create_autocmd('FileType', { - pattern = grammer_list, - callback = function() vim.treesitter.start() end, -}) - diff --git a/nvim/config/nvim-pack-lock.json b/nvim/config/nvim-pack-lock.json new file mode 100644 index 0000000..c714f6c --- /dev/null +++ b/nvim/config/nvim-pack-lock.json @@ -0,0 +1,78 @@ +{ + "plugins": { + "fzf-lua": { + "rev": "4deeecf611c0beba6455e6cf06e2c051a6169dd4", + "src": "https://github.com/ibhagwan/fzf-lua" + }, + "git-blame.nvim": { + "rev": "5c536e2d4134d064aa3f41575280bc8a2a0e03d7", + "src": "https://github.com/f-person/git-blame.nvim" + }, + "lualine.nvim": { + "rev": "f5d2a8570f8b736ddb9bb4be504355bcd6e15ec8", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, + "mason.nvim": { + "rev": "b03fb0f20bc1d43daf558cda981a2be22e73ac42", + "src": "https://github.com/mason-org/mason.nvim" + }, + "nvim-base16": { + "rev": "38e140f97b3cbefbf2cb29e32fcd098e43e77a42", + "src": "https://github.com/RRethy/nvim-base16" + }, + "nvim-lspconfig": { + "rev": "c588db330592fa477a70d2fee6ba20a57194bdc3", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "4916d6592ede8c07973490d9322f187e07dfefac", + "src": "https://github.com/nvim-treesitter/nvim-treesitter", + "version": "'main'" + }, + "nvim-treesitter-context": { + "rev": "b0c45cefe2c8f7b55fc46f34e563bc428ef99636", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-context" + }, + "nvim-treesitter-textobjects": { + "rev": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", + "version": "'main'" + }, + "nvim-web-devicons": { + "rev": "6e76c5e47e957fbf080b1fdac165c66dbd2e7cfb", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "oil.nvim": { + "rev": "0fcc83805ad11cf714a949c98c605ed717e0b83e", + "src": "https://github.com/stevearc/oil.nvim" + }, + "quick-scope": { + "rev": "6cee1d9e0b9ac0fbffeb538d4a5ba9f5628fabbc", + "src": "https://github.com/unblevable/quick-scope" + }, + "vim-fugitive": { + "rev": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0", + "src": "https://github.com/tpope/vim-fugitive" + }, + "vim-gurl": { + "rev": "de3e14440fa72e0deaa5cf6c02eef91be706d75a", + "src": "https://github.com/vitapluvia/vim-gurl" + }, + "vim-repeat": { + "rev": "65846025c15494983dafe5e3b46c8f88ab2e9635", + "src": "https://github.com/tpope/vim-repeat" + }, + "vim-searchindex": { + "rev": "b0788c8213210b3bd23b62847dd5a9ebbe4ad648", + "src": "https://github.com/google/vim-searchindex" + }, + "vim-surround": { + "rev": "3d188ed2113431cf8dac77be61b842acb64433d9", + "src": "https://github.com/tpope/vim-surround" + }, + "vim-unimpaired": { + "rev": "db65482581a28e4ccf355be297f1864a4e66985c", + "src": "https://github.com/tpope/vim-unimpaired" + } + } +} From 22f3727c7eb0ca95c77637ec31b6a1c944742c44 Mon Sep 17 00:00:00 2001 From: Or Elimelech Date: Thu, 9 Apr 2026 21:12:18 +0300 Subject: [PATCH 2/4] fix: configs --- nvim/config/lua/config/fzf.lua | 3 +++ nvim/config/lua/config/keymaps.lua | 3 --- nvim/config/lua/config/languages.lua | 37 +++++++++++++++++++++++++++ nvim/config/lua/config/lsp.lua | 22 +++++----------- nvim/config/lua/config/motion.lua | 12 ++++----- nvim/config/lua/config/treesitter.lua | 22 +++++----------- 6 files changed, 57 insertions(+), 42 deletions(-) create mode 100644 nvim/config/lua/config/languages.lua diff --git a/nvim/config/lua/config/fzf.lua b/nvim/config/lua/config/fzf.lua index a0695e1..53aa39a 100644 --- a/nvim/config/lua/config/fzf.lua +++ b/nvim/config/lua/config/fzf.lua @@ -7,6 +7,9 @@ require('fzf-lua').setup({ fzf_colors = true }) +local opts = { noremap = true, silent = true } + +vim.keymap.set('n', 'h', ':FzfLua helptags', opts) vim.keymap.set('n', 'f', ':FzfLua files', { noremap = true }) vim.keymap.set('n', 'gf', ':FzfLua git_files', { noremap = true }) vim.keymap.set('n', 'b', ':FzfLua buffers', { noremap = true }) diff --git a/nvim/config/lua/config/keymaps.lua b/nvim/config/lua/config/keymaps.lua index 32eb3d4..c7053db 100644 --- a/nvim/config/lua/config/keymaps.lua +++ b/nvim/config/lua/config/keymaps.lua @@ -1,8 +1,5 @@ local opts = { noremap = true, silent = true } --- Global -vim.keymap.set('n', 'h', ':FzfLua helptags', opts) - -- LSP vim.keymap.set('n', 'gD', ':FzfLua lsp_declarations', opts) vim.keymap.set('n', 'gi', ':FzfLua lsp_implementations', opts) diff --git a/nvim/config/lua/config/languages.lua b/nvim/config/lua/config/languages.lua new file mode 100644 index 0000000..5ea2519 --- /dev/null +++ b/nvim/config/lua/config/languages.lua @@ -0,0 +1,37 @@ +return { + -- Build systems + { treesitter = "make" }, + { treesitter = "cmake" }, + { treesitter = "dockerfile" }, + + -- Scripting languages + { treesitter = "bash", lsp = "bashls" }, + { treesitter = "lua", lsp = "lua_ls" }, + + -- Programming languages + { treesitter = "go", lsp = "gopls" }, + { treesitter = "gomod" }, + { treesitter = "gosum" }, + { treesitter = "rust" }, + { treesitter = "proto", lsp = "buf_ls" }, + { treesitter = "zig", lsp = "zls" }, + { treesitter = "gleam", lsp = "gleam" }, + { treesitter = "elixir" }, + { treesitter = "html" }, + { treesitter = "css" }, + { treesitter = "typescript", lsp = "ts_ls" }, + { treesitter = "javascript" }, + + -- Data and documentation + { treesitter = "sql" }, + { treesitter = "csv" }, + { treesitter = "markdown", lsp = "marksman" }, + + -- Config and IaC + { treesitter = "terraform", lsp = "terraformls" }, + { treesitter = "hcl" }, + { treesitter = "json" }, + { treesitter = "yaml" }, + { treesitter = "toml" }, + { treesitter = "regex" }, +} diff --git a/nvim/config/lua/config/lsp.lua b/nvim/config/lua/config/lsp.lua index 513c5ef..01bf5a5 100644 --- a/nvim/config/lua/config/lsp.lua +++ b/nvim/config/lua/config/lsp.lua @@ -5,22 +5,12 @@ vim.pack.add({ require('mason').setup() -local servers = { - "lua_ls", - "gopls", - "buf_ls", - "jsonls", - "html", - "htmx", - "cssls", - "ts_ls", - "bashls", - "terraformls", - "sqlls", - "zls", - "gleam", - "marksman", -} +local servers = vim + .iter(require("config.languages")) + :map(function(lang) return lang.lsp end) + :filter(function(lsp) return lsp end) + :flatten() + :totable() for _, server in ipairs(servers) do vim.lsp.enable(server) diff --git a/nvim/config/lua/config/motion.lua b/nvim/config/lua/config/motion.lua index e9589f3..842a6f7 100644 --- a/nvim/config/lua/config/motion.lua +++ b/nvim/config/lua/config/motion.lua @@ -1,9 +1,7 @@ -local gh = function(x) return 'https://github.com/' .. x end - vim.pack.add({ - gh('tpope/vim-surround'), - gh('tpope/vim-repeat'), - gh('tpope/vim-unimpaired'), - gh('unblevable/quick-scope'), - gh('google/vim-searchindex'), + 'https://github.com/tpope/vim-surround', + 'https://github.com/tpope/vim-repeat', + 'https://github.com/tpope/vim-unimpaired', + 'https://github.com/unblevable/quick-scope', + 'https://github.com/google/vim-searchindex', }) diff --git a/nvim/config/lua/config/treesitter.lua b/nvim/config/lua/config/treesitter.lua index ce7b578..e4e3598 100644 --- a/nvim/config/lua/config/treesitter.lua +++ b/nvim/config/lua/config/treesitter.lua @@ -25,22 +25,12 @@ require('nvim-treesitter').setup({ } }) --- Treesitter -local grammer_list = { - 'go', - 'gomod', - 'gosum', - 'javascript', - 'typescript', - 'rust', - 'zig', - 'gleam', - 'elixir', - 'bash', - 'lua', - 'terraform', - 'hcl', -} +local grammer_list = vim + .iter(require("config.languages")) + :map(function(grammer) return grammer.treesitter end) + :filter(function(grammer) return grammer end) + :flatten() + :totable() require('nvim-treesitter').install(grammer_list) From 40263b285d5a874f89c8d02e9672f497f28a79a2 Mon Sep 17 00:00:00 2001 From: Or Elimelech Date: Thu, 9 Apr 2026 21:47:19 +0300 Subject: [PATCH 3/4] refactor LspAttach --- nvim/config/init.lua | 26 +++++---- nvim/config/lua/config/autocmds.lua | 19 ++++--- nvim/config/lua/config/git.lua | 10 ++-- nvim/config/lua/config/keymaps.lua | 8 --- nvim/config/lua/config/lsp.lua | 84 +++++++++++++++-------------- 5 files changed, 74 insertions(+), 73 deletions(-) diff --git a/nvim/config/init.lua b/nvim/config/init.lua index 4fb99b7..12888d6 100644 --- a/nvim/config/init.lua +++ b/nvim/config/init.lua @@ -1,10 +1,16 @@ -require('config/opts') -require('config/keymaps') -require('config/theme') -require('config/oil') -require('config/treesitter') -require('config/lsp') -require('config/fzf') -require('config/motion') -require('config/autocmds') -require('config/git') +local configs = { + 'opts', + 'keymaps', + 'theme', + 'oil', + 'treesitter', + 'lsp', + 'fzf', + 'motion', + 'autocmds', + 'git', +} + +for _, config in ipairs(configs) do + require('config.' .. config) +end diff --git a/nvim/config/lua/config/autocmds.lua b/nvim/config/lua/config/autocmds.lua index 6334507..e71ede1 100644 --- a/nvim/config/lua/config/autocmds.lua +++ b/nvim/config/lua/config/autocmds.lua @@ -4,12 +4,17 @@ vim.api.nvim_create_autocmd({"BufRead", "BufNewFile"}, { }) vim.api.nvim_create_autocmd("FileType", { - pattern = {"lua", "ruby", "yaml", "html", "json"}, - callback = function () - vim.opt_local.tabstop = 2 - vim.opt_local.shiftwidth = 2 - vim.opt_local.softtabstop = 2 - vim.opt_local.expandtab = true - vim.opt_local.smartindent = true + pattern = { "lua", "ruby", "yaml", "html", "json" }, + callback = function() + local opts = { + tabstop = 2, + shiftwidth = 2, + softtabstop = 2, + expandtab = true, + smartindent = true, + } + for k, v in pairs(opts) do + vim.opt_local[k] = v + end end }) diff --git a/nvim/config/lua/config/git.lua b/nvim/config/lua/config/git.lua index c85bed4..c588a6f 100644 --- a/nvim/config/lua/config/git.lua +++ b/nvim/config/lua/config/git.lua @@ -1,9 +1,5 @@ -local gh = function(x) return 'https://github.com/' .. x end - vim.pack.add({ - gh('tpope/vim-fugitive'), -- Git client - - gh('vitapluvia/vim-gurl'), -- Github URL to clipboard - - gh('f-person/git-blame.nvim'), + 'https://github.com/tpope/vim-fugitive', -- Git client + 'https://github.com/vitapluvia/vim-gurl', -- Github URL to clipboard + 'https://github.com/f-person/git-blame.nvim', }) diff --git a/nvim/config/lua/config/keymaps.lua b/nvim/config/lua/config/keymaps.lua index c7053db..72d0957 100644 --- a/nvim/config/lua/config/keymaps.lua +++ b/nvim/config/lua/config/keymaps.lua @@ -1,13 +1,5 @@ local opts = { noremap = true, silent = true } --- LSP -vim.keymap.set('n', 'gD', ':FzfLua lsp_declarations', opts) -vim.keymap.set('n', 'gi', ':FzfLua lsp_implementations', opts) -vim.keymap.set('n', 'gr', ':FzfLua lsp_references', opts) -vim.keymap.set('n', 'g0', ':FzfLua lsp_document_symbols', opts) -vim.keymap.set('n', 'gW', ':FzfLua lsp_live_workspace_symbols', opts) -vim.keymap.set('n', 'cl', ':lua vim.lsp.codelens.run()', opts) - -- nvim-test vim.keymap.set('n', 'tf', ':TestFile', opts) vim.keymap.set('n', 'tt', ':TestNearest', opts) diff --git a/nvim/config/lua/config/lsp.lua b/nvim/config/lua/config/lsp.lua index 01bf5a5..b236b95 100644 --- a/nvim/config/lua/config/lsp.lua +++ b/nvim/config/lua/config/lsp.lua @@ -20,56 +20,58 @@ end vim.opt.completeopt = 'menu,menuone,noselect,popup' vim.opt.autocomplete = true +-- Helper for code actions on save (like goimports or ts-organize-imports) +local function sync_code_action(bufnr, client, kind) + local params = vim.lsp.util.make_range_params() + params.context = { only = { kind } } + local result = vim.lsp.buf_request_sync(bufnr, "textDocument/codeAction", params, 1000) + for _, res in pairs(result or {}) do + for _, action in pairs(res.result or {}) do + if action.edit then + vim.lsp.util.apply_workspace_edit(action.edit, client.offset_encoding) + elseif action.command then + vim.lsp.buf.execute_command(action.command) + end + end + end +end + vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("lsp_completion", { clear = true }), + group = vim.api.nvim_create_augroup("lsp_attach_config", { clear = true }), callback = function(args) local client_id = args.data.client_id - if not client_id then - return - end + if not client_id then return end local client = vim.lsp.get_client_by_id(client_id) + local bufnr = args.buf + if client and client:supports_method("textDocument/completion") then - -- Enable native LSP completion for this client + buffer - vim.lsp.completion.enable(true, client_id, args.buf, { - autotrigger = true, -- auto-show menu as you type (recommended) - -- You can also set { autotrigger = false } and trigger manually with - }) + vim.lsp.completion.enable(true, client_id, bufnr, { autotrigger = true }) end - end, -}) -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = {"*.go"}, - callback = function() - -- Format the file - vim.lsp.buf.format({ - async = false, - }) + local opts = { buffer = bufnr, silent = true } + vim.keymap.set('n', 'gD', ':FzfLua lsp_declarations', opts) + vim.keymap.set('n', 'gi', ':FzfLua lsp_implementations', opts) + vim.keymap.set('n', 'gr', ':FzfLua lsp_references', opts) + vim.keymap.set('n', 'g0', ':FzfLua lsp_document_symbols', opts) + vim.keymap.set('n', 'gW', ':FzfLua lsp_live_workspace_symbols', opts) + vim.keymap.set('n', 'cl', function() vim.lsp.codelens.run() end, opts) - -- Organize imports - local params = vim.lsp.util.make_range_params() - params.context = { only = { "source.organizeImports" } } + -- Format on save + if client and client:supports_method("textDocument/formatting") then + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + callback = function() + -- 1. Standard LSP Format + vim.lsp.buf.format({ bufnr = bufnr, async = false }) - local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 1000) - if not result then return end - - for _, res in pairs(result) do - for _, action in pairs(res.result or {}) do - if action.edit then - vim.lsp.util.apply_workspace_edit(action.edit, "utf-16") - else - vim.lsp.buf.execute_command(action.command) - end - end + -- 2. Language-specific "Fixups" + local ft = vim.bo[bufnr].filetype + if ft == "go" then + sync_code_action(bufnr, client, "source.organizeImports") + end + end, + }) end - end -}) - -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = {"*.tf"}, - callback = function() - vim.lsp.buf.format() - end + end, }) - From 7f6b6f168849d8a5f30007cedb60c6a7a4dbcf25 Mon Sep 17 00:00:00 2001 From: Or Elimelech Date: Sun, 12 Apr 2026 17:35:57 +0300 Subject: [PATCH 4/4] chore: move to plugin/ --- nvim/config/init.lua | 18 +---- nvim/config/lua/{config => }/autocmds.lua | 0 nvim/config/lua/config/fzf.lua | 21 ----- nvim/config/lua/config/git.lua | 5 -- nvim/config/lua/config/keymaps.lua | 5 -- nvim/config/lua/config/lsp.lua | 77 ------------------- nvim/config/lua/config/motion.lua | 7 -- nvim/config/lua/config/oil.lua | 19 ----- nvim/config/lua/config/theme.lua | 39 ---------- nvim/config/lua/config/treesitter.lua | 40 ---------- nvim/config/lua/{config => }/languages.lua | 0 .../lua/{config/opts.lua => options.lua} | 0 nvim/config/nvim-pack-lock.json | 12 ++- 13 files changed, 10 insertions(+), 233 deletions(-) rename nvim/config/lua/{config => }/autocmds.lua (100%) delete mode 100644 nvim/config/lua/config/fzf.lua delete mode 100644 nvim/config/lua/config/git.lua delete mode 100644 nvim/config/lua/config/keymaps.lua delete mode 100644 nvim/config/lua/config/lsp.lua delete mode 100644 nvim/config/lua/config/motion.lua delete mode 100644 nvim/config/lua/config/oil.lua delete mode 100644 nvim/config/lua/config/theme.lua delete mode 100644 nvim/config/lua/config/treesitter.lua rename nvim/config/lua/{config => }/languages.lua (100%) rename nvim/config/lua/{config/opts.lua => options.lua} (100%) diff --git a/nvim/config/init.lua b/nvim/config/init.lua index 12888d6..c21483b 100644 --- a/nvim/config/init.lua +++ b/nvim/config/init.lua @@ -1,16 +1,2 @@ -local configs = { - 'opts', - 'keymaps', - 'theme', - 'oil', - 'treesitter', - 'lsp', - 'fzf', - 'motion', - 'autocmds', - 'git', -} - -for _, config in ipairs(configs) do - require('config.' .. config) -end +require('options') +require('autocmds') diff --git a/nvim/config/lua/config/autocmds.lua b/nvim/config/lua/autocmds.lua similarity index 100% rename from nvim/config/lua/config/autocmds.lua rename to nvim/config/lua/autocmds.lua diff --git a/nvim/config/lua/config/fzf.lua b/nvim/config/lua/config/fzf.lua deleted file mode 100644 index 53aa39a..0000000 --- a/nvim/config/lua/config/fzf.lua +++ /dev/null @@ -1,21 +0,0 @@ -vim.pack.add({ - 'https://github.com/ibhagwan/fzf-lua', - 'https://github.com/nvim-tree/nvim-web-devicons', -}) - -require('fzf-lua').setup({ - fzf_colors = true -}) - -local opts = { noremap = true, silent = true } - -vim.keymap.set('n', 'h', ':FzfLua helptags', opts) -vim.keymap.set('n', 'f', ':FzfLua files', { noremap = true }) -vim.keymap.set('n', 'gf', ':FzfLua git_files', { noremap = true }) -vim.keymap.set('n', 'b', ':FzfLua buffers', { noremap = true }) -vim.keymap.set('n', 'l', ':FzfLua lines', { noremap = true }) -vim.keymap.set('n', 'gs', ':FzfLua git_status', { noremap = true }) -vim.keymap.set('n', 'C', ':FzfLua git_commits', { noremap = true }) -vim.keymap.set('n', 'c', ':FzfLua git_bcommits', { noremap = true }) -vim.keymap.set('n', 'g', ':FzfLua grep_project', { noremap = true }) -vim.keymap.set('n', 'km', ':FzfLua keymaps', { noremap = true }) diff --git a/nvim/config/lua/config/git.lua b/nvim/config/lua/config/git.lua deleted file mode 100644 index c588a6f..0000000 --- a/nvim/config/lua/config/git.lua +++ /dev/null @@ -1,5 +0,0 @@ -vim.pack.add({ - 'https://github.com/tpope/vim-fugitive', -- Git client - 'https://github.com/vitapluvia/vim-gurl', -- Github URL to clipboard - 'https://github.com/f-person/git-blame.nvim', -}) diff --git a/nvim/config/lua/config/keymaps.lua b/nvim/config/lua/config/keymaps.lua deleted file mode 100644 index 72d0957..0000000 --- a/nvim/config/lua/config/keymaps.lua +++ /dev/null @@ -1,5 +0,0 @@ -local opts = { noremap = true, silent = true } - --- nvim-test -vim.keymap.set('n', 'tf', ':TestFile', opts) -vim.keymap.set('n', 'tt', ':TestNearest', opts) diff --git a/nvim/config/lua/config/lsp.lua b/nvim/config/lua/config/lsp.lua deleted file mode 100644 index b236b95..0000000 --- a/nvim/config/lua/config/lsp.lua +++ /dev/null @@ -1,77 +0,0 @@ -vim.pack.add({ - 'https://github.com/neovim/nvim-lspconfig', - 'https://github.com/mason-org/mason.nvim', -}) - -require('mason').setup() - -local servers = vim - .iter(require("config.languages")) - :map(function(lang) return lang.lsp end) - :filter(function(lsp) return lsp end) - :flatten() - :totable() - -for _, server in ipairs(servers) do - vim.lsp.enable(server) -end - --- Enable autocomplete -vim.opt.completeopt = 'menu,menuone,noselect,popup' -vim.opt.autocomplete = true - --- Helper for code actions on save (like goimports or ts-organize-imports) -local function sync_code_action(bufnr, client, kind) - local params = vim.lsp.util.make_range_params() - params.context = { only = { kind } } - local result = vim.lsp.buf_request_sync(bufnr, "textDocument/codeAction", params, 1000) - for _, res in pairs(result or {}) do - for _, action in pairs(res.result or {}) do - if action.edit then - vim.lsp.util.apply_workspace_edit(action.edit, client.offset_encoding) - elseif action.command then - vim.lsp.buf.execute_command(action.command) - end - end - end -end - -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("lsp_attach_config", { clear = true }), - callback = function(args) - local client_id = args.data.client_id - if not client_id then return end - - local client = vim.lsp.get_client_by_id(client_id) - local bufnr = args.buf - - if client and client:supports_method("textDocument/completion") then - vim.lsp.completion.enable(true, client_id, bufnr, { autotrigger = true }) - end - - local opts = { buffer = bufnr, silent = true } - vim.keymap.set('n', 'gD', ':FzfLua lsp_declarations', opts) - vim.keymap.set('n', 'gi', ':FzfLua lsp_implementations', opts) - vim.keymap.set('n', 'gr', ':FzfLua lsp_references', opts) - vim.keymap.set('n', 'g0', ':FzfLua lsp_document_symbols', opts) - vim.keymap.set('n', 'gW', ':FzfLua lsp_live_workspace_symbols', opts) - vim.keymap.set('n', 'cl', function() vim.lsp.codelens.run() end, opts) - - -- Format on save - if client and client:supports_method("textDocument/formatting") then - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - -- 1. Standard LSP Format - vim.lsp.buf.format({ bufnr = bufnr, async = false }) - - -- 2. Language-specific "Fixups" - local ft = vim.bo[bufnr].filetype - if ft == "go" then - sync_code_action(bufnr, client, "source.organizeImports") - end - end, - }) - end - end, -}) diff --git a/nvim/config/lua/config/motion.lua b/nvim/config/lua/config/motion.lua deleted file mode 100644 index 842a6f7..0000000 --- a/nvim/config/lua/config/motion.lua +++ /dev/null @@ -1,7 +0,0 @@ -vim.pack.add({ - 'https://github.com/tpope/vim-surround', - 'https://github.com/tpope/vim-repeat', - 'https://github.com/tpope/vim-unimpaired', - 'https://github.com/unblevable/quick-scope', - 'https://github.com/google/vim-searchindex', -}) diff --git a/nvim/config/lua/config/oil.lua b/nvim/config/lua/config/oil.lua deleted file mode 100644 index b94b19f..0000000 --- a/nvim/config/lua/config/oil.lua +++ /dev/null @@ -1,19 +0,0 @@ -vim.pack.add({ - 'https://github.com/nvim-tree/nvim-web-devicons', - 'https://github.com/stevearc/oil.nvim', -}) - -require('oil').setup({ - float = { - padding = 2, -- Padding around the floating window - max_width = 0.4, -- Max width (90% of screen) - max_height = 0.7, -- Max height (90% of screen) - border = "rounded", -- 'single', 'double', 'shadow', etc. - win_options = { - winblend = 10, -- Transparency - }, - }, -}) - --- Oil.nvim -vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }) diff --git a/nvim/config/lua/config/theme.lua b/nvim/config/lua/config/theme.lua deleted file mode 100644 index 0a1253d..0000000 --- a/nvim/config/lua/config/theme.lua +++ /dev/null @@ -1,39 +0,0 @@ -vim.pack.add({ - 'https://github.com/nvim-tree/nvim-web-devicons', - 'https://github.com/RRethy/nvim-base16', - 'https://github.com/nvim-lualine/lualine.nvim', -}) - --- Theme -vim.cmd.colorscheme('base16-gruvbox-dark-hard') - -require('lualine').setup({ - sections = { - lualine_b = { - { - "branch", - fmt = function(str) - if #str > 20 then - return str:sub(1, 17) .. "..." - end - return str - end, - }, - "diff", - "diagnostics", - }, - lualine_c = { - { - 'filename', - path = 1, - fmt = function(path) - local parts = vim.split(path, "/") - if #parts > 4 then - return ".../" .. table.concat(parts, "/", #parts - 2) - end - return path - end, - }, - }, - } -}) diff --git a/nvim/config/lua/config/treesitter.lua b/nvim/config/lua/config/treesitter.lua deleted file mode 100644 index e4e3598..0000000 --- a/nvim/config/lua/config/treesitter.lua +++ /dev/null @@ -1,40 +0,0 @@ -vim.pack.add({ - { src = 'https://github.com/nvim-treesitter/nvim-treesitter', version = 'main' }, - { src = 'https://github.com/nvim-treesitter/nvim-treesitter-context' }, - { src = 'https://github.com/nvim-treesitter/nvim-treesitter-textobjects', version = 'main' }, -}) - -require('nvim-treesitter').setup({ - incremental_selection = { - enable = true, - }, - - textobjects = { - select = { - enable = true, - - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - } - } - } -}) - -local grammer_list = vim - .iter(require("config.languages")) - :map(function(grammer) return grammer.treesitter end) - :filter(function(grammer) return grammer end) - :flatten() - :totable() - -require('nvim-treesitter').install(grammer_list) - -vim.api.nvim_create_autocmd('FileType', { - pattern = grammer_list, - callback = function() vim.treesitter.start() end, -}) diff --git a/nvim/config/lua/config/languages.lua b/nvim/config/lua/languages.lua similarity index 100% rename from nvim/config/lua/config/languages.lua rename to nvim/config/lua/languages.lua diff --git a/nvim/config/lua/config/opts.lua b/nvim/config/lua/options.lua similarity index 100% rename from nvim/config/lua/config/opts.lua rename to nvim/config/lua/options.lua diff --git a/nvim/config/nvim-pack-lock.json b/nvim/config/nvim-pack-lock.json index c714f6c..ad1392a 100644 --- a/nvim/config/nvim-pack-lock.json +++ b/nvim/config/nvim-pack-lock.json @@ -1,7 +1,11 @@ { "plugins": { + "blink.cmp": { + "rev": "456d38d1cd3743926f329204c2340f3e7840aad6", + "src": "https://github.com/saghen/blink.cmp" + }, "fzf-lua": { - "rev": "4deeecf611c0beba6455e6cf06e2c051a6169dd4", + "rev": "657c1bbb7357c61e26a20d868b53a460b05c18c0", "src": "https://github.com/ibhagwan/fzf-lua" }, "git-blame.nvim": { @@ -9,7 +13,7 @@ "src": "https://github.com/f-person/git-blame.nvim" }, "lualine.nvim": { - "rev": "f5d2a8570f8b736ddb9bb4be504355bcd6e15ec8", + "rev": "a905eeebc4e63fdc48b5135d3bf8aea5618fb21c", "src": "https://github.com/nvim-lualine/lualine.nvim" }, "mason.nvim": { @@ -21,7 +25,7 @@ "src": "https://github.com/RRethy/nvim-base16" }, "nvim-lspconfig": { - "rev": "c588db330592fa477a70d2fee6ba20a57194bdc3", + "rev": "cb5bc0b2b35a6d513e3298d285db81453e791f4f", "src": "https://github.com/neovim/nvim-lspconfig" }, "nvim-treesitter": { @@ -39,7 +43,7 @@ "version": "'main'" }, "nvim-web-devicons": { - "rev": "6e76c5e47e957fbf080b1fdac165c66dbd2e7cfb", + "rev": "c72328a5494b4502947a022fe69c0c47e53b6aa6", "src": "https://github.com/nvim-tree/nvim-web-devicons" }, "oil.nvim": {