From 5ccf595db22eb4055814399879fdd08250f04f63 Mon Sep 17 00:00:00 2001 From: Shahab Dogar Date: Wed, 25 Mar 2026 15:45:19 +0500 Subject: [PATCH] fix: update neovim configs --- dotfiles/nvim/flake.nix | 1 + dotfiles/nvim/lazy-lock.json | 21 +++---- .../nvim/lua/custom/configs/formatter.lua | 4 -- .../nvim/lua/custom/configs/lspconfig.lua | 62 ++++++++++--------- dotfiles/nvim/lua/custom/configs/null-ls.lua | 28 --------- dotfiles/nvim/lua/custom/init.lua | 2 +- dotfiles/nvim/lua/custom/mappings.lua | 38 ------------ dotfiles/nvim/lua/custom/plugins.lua | 9 +-- .../nvim/lua/plugins/configs/lspconfig.lua | 6 +- 9 files changed, 48 insertions(+), 123 deletions(-) delete mode 100644 dotfiles/nvim/lua/custom/configs/null-ls.lua diff --git a/dotfiles/nvim/flake.nix b/dotfiles/nvim/flake.nix index 117a4ef..e8faa64 100644 --- a/dotfiles/nvim/flake.nix +++ b/dotfiles/nvim/flake.nix @@ -27,6 +27,7 @@ stylua ripgrep fd + nil nodejs_24 python313 diff --git a/dotfiles/nvim/lazy-lock.json b/dotfiles/nvim/lazy-lock.json index cd70b44..ff02080 100644 --- a/dotfiles/nvim/lazy-lock.json +++ b/dotfiles/nvim/lazy-lock.json @@ -1,6 +1,6 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, - "LuaSnip": { "branch": "master", "commit": "de10d8414235b0a8cabfeba60d07c24304e71f5c" }, + "LuaSnip": { "branch": "master", "commit": "642b0c595e11608b4c18219e93b88d7637af27bc" }, "avante.nvim": { "branch": "main", "commit": "348be57354a8ac232b599474069b0e518308a9a3" }, "base46": { "branch": "v2.0", "commit": "85de6cdb2d3c85d0aee53aea0569e73fdaf3df4e" }, "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" }, @@ -9,15 +9,15 @@ "cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" }, "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "copilot.lua": { "branch": "master", "commit": "0552b44fceedf0c4cba2cd4953d3976633b2509a" }, + "copilot.lua": { "branch": "master", "commit": "538f15c4eaad8661389a4a0d1ace2d6e079fac29" }, "copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" }, "crates.nvim": { "branch": "main", "commit": "ac9fa498a9edb96dc3056724ff69d5f40b898453" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "formatter.nvim": { "branch": "master", "commit": "b9d7f853da1197b83b8edb4cc4952f7ad3a42e41" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "fzf-lua": { "branch": "main", "commit": "8a79ee54d6216d10b2f153921a12b152be0c1a20" }, + "fzf-lua": { "branch": "main", "commit": "3b01dc83a893749f5ae4639f1aa0af523821840a" }, "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, - "gitsigns.nvim": { "branch": "main", "commit": "7c4faa3540d0781a28588cafbd4dd187a28ac6e3" }, + "gitsigns.nvim": { "branch": "main", "commit": "0a80125bace82d82847d40bc2c38a22d62c6dc2d" }, "grpc-nvim": { "branch": "main", "commit": "cd235398a9922ae412f59ebeabb0b13957be0d39" }, "img-clip.nvim": { "branch": "main", "commit": "b6ddfb97b5600d99afe3452d707444afda658aca" }, "indent-blankline.nvim": { "branch": "master", "commit": "b7aa0aed55887edfaece23f7b46ab22232fc8741" }, @@ -25,22 +25,21 @@ "lazydocker.nvim": { "branch": "main", "commit": "b69ff84a6223de39d34a150b980d3b9ef19549fb" }, "lazygit.nvim": { "branch": "main", "commit": "a04ad0dbc725134edbee3a5eea29290976695357" }, "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, - "mini.pick": { "branch": "main", "commit": "8f196683edb7e199dc392a5830cced4ba05671db" }, + "mini.pick": { "branch": "main", "commit": "fe079c2bd894a5ee70b62f23d819620ef40c4949" }, "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, "noice.nvim": { "branch": "main", "commit": "7bfd942445fb63089b59f97ca487d605e715f155" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, "nvim-autopairs": { "branch": "master", "commit": "59bce2eef357189c3305e25bc6dd2d138c1683f5" }, "nvim-cmp": { "branch": "main", "commit": "da88697d7f45d16852c6b2769dc52387d1ddc45f" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "85a5e83cd4daa258cf95c3204e277991d6fbe747" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "32fcc38ab7e559f24763f6b3d9c37658ebf407d6" }, "nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, - "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-lspconfig": { "branch": "master", "commit": "841c6d4139aedb8a3f2baf30cef5327371385b93" }, + "nvim-dap-ui": { "branch": "master", "commit": "f5b6673f374626515401c5bc51b005f784a4f252" }, + "nvim-lspconfig": { "branch": "master", "commit": "4daa1436595dbce4c6151f75c38a0d855796c554" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, - "nvim-tree.lua": { "branch": "master", "commit": "dfeeb12aaae37f23285101cf875416c29052b22a" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-tree.lua": { "branch": "master", "commit": "3d385d3346e4883d60dc37cf642bd47bed78a46e" }, + "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, "nvim-web-devicons": { "branch": "master", "commit": "d7462543c9e366c0d196c7f67a945eaaf5d99414" }, "nvterm": { "branch": "main", "commit": "9d7ba3b6e368243175d38e1ec956e0476fd86ed9" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, diff --git a/dotfiles/nvim/lua/custom/configs/formatter.lua b/dotfiles/nvim/lua/custom/configs/formatter.lua index 81d00a8..e1b4377 100644 --- a/dotfiles/nvim/lua/custom/configs/formatter.lua +++ b/dotfiles/nvim/lua/custom/configs/formatter.lua @@ -9,8 +9,4 @@ local M = { }, } -vim.api.nvim_create_autocmd({ "BufWritePost" }, { - command = "FormatWriteLock", -}) - return M diff --git a/dotfiles/nvim/lua/custom/configs/lspconfig.lua b/dotfiles/nvim/lua/custom/configs/lspconfig.lua index b87b09b..f38f1c2 100644 --- a/dotfiles/nvim/lua/custom/configs/lspconfig.lua +++ b/dotfiles/nvim/lua/custom/configs/lspconfig.lua @@ -1,48 +1,50 @@ local config = require("plugins.configs.lspconfig") local on_attach = config.on_attach local capabilities = config.capabilities -local lspconfig = require("lspconfig") -local function organize_imports() - local params = { - command = "_typescript.organizeImports", - arguments = { vim.api.nvim_buf_get_name(0) }, - } - vim.lsp.buf.execute_command(params) +local custom_on_attach = function(client, bufnr) + on_attach(client, bufnr) + + if client.name == "ts_ls" then + vim.api.nvim_buf_create_user_command(bufnr, "OrganizeImports", function() + local params = { + command = "_typescript.organizeImports", + arguments = { vim.api.nvim_buf_get_name(0) }, + } + vim.lsp.buf.execute_command(params) + end, { desc = "Organize Imports" }) + end end -lspconfig.ts_ls.setup { - on_attach = on_attach, +vim.lsp.config("ts_ls", { + on_attach = custom_on_attach, capabilities = capabilities, init_options = { preferences = { disablesuggestions = true, } }, - commands = { - OrganizeImports = { - organize_imports, - description = "Organize Imports", - }, - } -} +}) +vim.lsp.enable("ts_ls") -lspconfig.terraformls.setup { +vim.lsp.config("terraformls", { on_attach = on_attach, capabilities = capabilities, -} +}) +vim.lsp.enable("terraformls") -lspconfig.tflint.setup { +vim.lsp.config("tflint", { on_attach = on_attach, capabilities = capabilities, -} +}) +vim.lsp.enable("tflint") -lspconfig.gopls.setup { +vim.lsp.config("gopls", { on_attach = on_attach, capabilities = capabilities, cmd = { "gopls" }, filetypes = { "go", "gomod", "gowork", "gotempl" }, - root_dir = lspconfig.util.root_pattern("go.mod", "go.work"), + root_markers = { "go.mod", "go.work" }, settings = { gopls = { completeUnimported = true, @@ -52,20 +54,19 @@ lspconfig.gopls.setup { }, }, }, -} +}) +vim.lsp.enable("gopls") -lspconfig.pyright.setup { +vim.lsp.config("pyright", { on_attach = on_attach, capabilities = capabilities, filetypes = { "python" }, -} +}) +vim.lsp.enable("pyright") -lspconfig.gleam.setup({}) - -lspconfig.nil_ls.setup { +vim.lsp.config("nil_ls", { on_attach = on_attach, capabilities = capabilities, - autostart = true, cmd = { "nil" }, filetypes = { "nix" }, settings = { @@ -76,4 +77,5 @@ lspconfig.nil_ls.setup { }, }, }, -} +}) +vim.lsp.enable("nil_ls") \ No newline at end of file diff --git a/dotfiles/nvim/lua/custom/configs/null-ls.lua b/dotfiles/nvim/lua/custom/configs/null-ls.lua deleted file mode 100644 index f2fc53b..0000000 --- a/dotfiles/nvim/lua/custom/configs/null-ls.lua +++ /dev/null @@ -1,28 +0,0 @@ -local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -local null_ls = require("null-ls") - -local opts = { - sources = { - null_ls.builtins.formatting.black, - null_ls.builtins.diagnostics.mypy, - null_ls.builtins.diagnostics.ruff, - }, - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ - group = augroup, - buffer = bufnr, - }) - - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ bufnr = bufnr }) - end, - }) - end - end, -} - -return opts diff --git a/dotfiles/nvim/lua/custom/init.lua b/dotfiles/nvim/lua/custom/init.lua index 011d8fe..e7307c1 100644 --- a/dotfiles/nvim/lua/custom/init.lua +++ b/dotfiles/nvim/lua/custom/init.lua @@ -3,7 +3,7 @@ vim.opt.colorcolumn = "80" vim.g.copilot_no_tab_map = true vim.api.nvim_set_keymap("i", "", 'copilot#Accept("")', { silent = true, expr = true, noremap = true, script = true }) vim.wo.relativenumber = true -vim.g.scrolloff = 8 +vim.opt.scrolloff = 8 -- Auto-reload files when changed externally vim.opt.autoread = true diff --git a/dotfiles/nvim/lua/custom/mappings.lua b/dotfiles/nvim/lua/custom/mappings.lua index ebf87a5..7eb8d58 100644 --- a/dotfiles/nvim/lua/custom/mappings.lua +++ b/dotfiles/nvim/lua/custom/mappings.lua @@ -27,12 +27,6 @@ M['rust-tools'] = { M.dap = { n = { - ["dl"] = { - function () - require("dap") - end, - "Load DAP", - }, ["dt"] = { " DapToggleBreakpoint ", "Toggle breakpoint", @@ -61,25 +55,6 @@ M.dap_python = { } } -M.dap_go = { - plugin = true, - - n = { - ["gdt"] = { - function () - require("dap-go").debug_test() - end, - "Debug go test", - }, - ["gdl"] = { - function () - require("dap-go").debug_last() - end, - "Toggle breakpoint", - }, - } -} - M.lazygit = { n = { ["gg"] = { @@ -142,19 +117,6 @@ M.worktree = { }, } -M.neorg = { - n = { - ["ni"] = { - " Neorg index ", - "Neorg index", - }, - ["nr"] = { - " Neorg return ", - "Return from index", - }, - }, -} - M.general = { n = { [""] = { diff --git a/dotfiles/nvim/lua/custom/plugins.lua b/dotfiles/nvim/lua/custom/plugins.lua index 2ae91b2..f457a53 100644 --- a/dotfiles/nvim/lua/custom/plugins.lua +++ b/dotfiles/nvim/lua/custom/plugins.lua @@ -13,7 +13,7 @@ local plugins = { "rcarriga/nvim-dap-ui", "nvim-neotest/nvim-nio", }, - config = function (_, opts) + config = function (_, _) local path = "~/.local/share/nvim/mason/packages/debugpy/venv/bin/python" require("dap-python").setup(path) end @@ -53,13 +53,6 @@ local plugins = { { "ThePrimeagen/git-worktree.nvim", }, - { - "jose-elias-alvarez/null-ls.nvim", - ft = { "python" }, - config = function () - require "custom.configs.null-ls" - end, - }, { "folke/noice.nvim", event = "VeryLazy", diff --git a/dotfiles/nvim/lua/plugins/configs/lspconfig.lua b/dotfiles/nvim/lua/plugins/configs/lspconfig.lua index 37685e3..65a06b2 100644 --- a/dotfiles/nvim/lua/plugins/configs/lspconfig.lua +++ b/dotfiles/nvim/lua/plugins/configs/lspconfig.lua @@ -40,11 +40,10 @@ M.capabilities.textDocument.completion.completionItem = { }, } -require("lspconfig").lua_ls.setup { +vim.lsp.config("lua_ls", { on_init = M.on_init, on_attach = M.on_attach, capabilities = M.capabilities, - settings = { Lua = { diagnostics = { @@ -62,6 +61,7 @@ require("lspconfig").lua_ls.setup { }, }, }, -} +}) +vim.lsp.enable("lua_ls") return M