diff --git a/nvim/init.lua b/nvim/init.lua index 384ddc6..6a8a13b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -3,7 +3,6 @@ local vim = vim local fn = vim.fn vim.g.mapleader = "\\" vim.g.maplocalleader = "\\" - vim.g.noswapfile = true vim.g.python3_host_prog = fn.exepath("python3") diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 29028d5..f232cdc 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -11,7 +11,7 @@ "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, "cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, - "fidget.nvim": { "branch": "main", "commit": "4d5858bd4c471c895060e1b9f3575f1551184dc5" }, + "fidget.nvim": { "branch": "main", "commit": "3f5475949679953af6d78654db29b944fa826e6a" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, @@ -19,12 +19,12 @@ "mini.icons": { "branch": "main", "commit": "f9a177c11daa7829389b7b6eaaec8b8a5c47052d" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "nightfox.nvim": { "branch": "main", "commit": "ba47d4b4c5ec308718641ba7402c143836f35aa9" }, - "none-ls-extras.nvim": { "branch": "main", "commit": "52628966ffc5b49cf0dbbe4d8733bacede9e7e8b" }, - "none-ls.nvim": { "branch": "main", "commit": "f0b3dc073153a08fd1e32869ed30b87a3bb4230f" }, + "none-ls-extras.nvim": { "branch": "main", "commit": "974bf1cd73fa3f0291211212ad60f8fe6fdd68d7" }, + "none-ls.nvim": { "branch": "main", "commit": "78111a97cebed3dfda8157af8141bf1915cfc327" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-colorizer.lua": { "branch": "master", "commit": "51cf7c995ed1eb6642aecf19067ee634fa1b6ba2" }, - "nvim-lspconfig": { "branch": "master", "commit": "d9879110d0422a566fa01d732556f4d5515e1738" }, - "nvim-surround": { "branch": "main", "commit": "a868c256c861044beb9794b4dd126480dcdfbdad" }, + "nvim-lspconfig": { "branch": "master", "commit": "b3cce1419ca67871ae782b3e529652f8a016f0de" }, + "nvim-surround": { "branch": "main", "commit": "75de1782c781961e392efcca57601bf436f4d550" }, "nvim-tree.lua": { "branch": "master", "commit": "e179ad2f83b5955ab0af653069a493a1828c2697" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, @@ -34,5 +34,5 @@ "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, "vim-floaterm": { "branch": "master", "commit": "fd4bdd66eca56c6cc59f2119e4447496d8cde2ea" }, "vim-illuminate": { "branch": "master", "commit": "0d1e93684da00ab7c057410fecfc24f434698898" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } + "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } } diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index ee62465..0e95c77 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -66,10 +66,10 @@ return { 'nvim-telescope/telescope.nvim', dependencies = { 'nvim-lua/plenary.nvim' }, keys = { - { "ff", "Telescope live_grep", desc = "Fuzzy grep across workspace" }, - { "fb", "Telescope buffers", desc = "Find buffer" }, - { "fp", "lua require'telescope.builtin'.git_files{}", desc="Find in project"}, - { "p", "Telescope diagnostics", desc = "Show diagnostics for buffer"} + { "ff", "Telescope live_grep", desc = "Fuzzy grep across workspace" }, + { "fb", "Telescope buffers", desc = "Find buffer" }, + { "fp", "lua require'telescope.builtin'.git_files{}", desc = "Find in project" }, + { "p", "Telescope diagnostics", desc = "Show diagnostics for buffer" } } }, { @@ -84,6 +84,7 @@ return { }, { 'lewis6991/gitsigns.nvim', + event = { "BufReadPre", "BufNewFile" }, keys = { { 'hd', 'Gitsigns diffthis', desc = "Show Git diff" }, { 'hr', 'Gitsigns reset_hunk', desc = "Git reset hunk" }, diff --git a/nvim/lua/plugins/lspconfig.lua b/nvim/lua/plugins/lspconfig.lua index 5dcddfe..8c30b50 100644 --- a/nvim/lua/plugins/lspconfig.lua +++ b/nvim/lua/plugins/lspconfig.lua @@ -1,6 +1,10 @@ -local augroup = vim.api.nvim_create_augroup("Lspformatting", {}) +local fmt_group = vim.api.nvim_create_augroup("Lspformatting", { clear = true }) + +local on_attach = function(event) + local id = vim.tbl_get(event, 'data', 'client_id') + local client = id and vim.lsp.get_client_by_id(id) + local bufnr = event.buf -local on_attach = function(client, bufnr) if (not bufnr) then return end @@ -30,26 +34,43 @@ local on_attach = function(client, bufnr) -- format on save does not work for python for some reason if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_clear_autocmds({ group = fmt_group, buffer = bufnr }) vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, + group = fmt_group, buffer = bufnr, callback = function() vim.lsp.buf.format({ async = false, bufnr = bufnr, + timeout_ms = 10000, }) end }) end end +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('LspAttachGroup', { clear = true }), + callback = on_attach, +}) + local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {}) vim.api.nvim_create_autocmd("VimLeave", { group = on_leave_group, command = "silent !killall -q eslint_d", }) +vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '✘', + [vim.diagnostic.severity.WARN] = '▲', + [vim.diagnostic.severity.HINT] = '⚑', + [vim.diagnostic.severity.INFO] = '»', + }, + }, + -- virtual_text = true, +}) return { { @@ -61,17 +82,18 @@ return { 'j-hui/fidget.nvim', }, config = function() - local lsp = require("lspconfig") - local lspconfig_defaults = lsp.util.default_config - lspconfig_defaults.capabilities = vim.tbl_deep_extend( + local lspconfig_defaults = require('lspconfig').util.default_config + local capabilities = vim.tbl_deep_extend( 'force', lspconfig_defaults.capabilities, require('cmp_nvim_lsp').default_capabilities() ) - --local capabilities = require('cmp_nvim_lsp').default_capabilities() - lsp.lua_ls.setup({ - on_attach = on_attach, + vim.lsp.config('*', { + capabilities = capabilities + }) + + vim.lsp.config("lua_ls", { settings = { Lua = { diagnostics = { @@ -81,25 +103,7 @@ return { } }) - lsp.clangd.setup { on_attach = on_attach } - lsp.ts_ls.setup { on_attach = on_attach } -- typescript - lsp.hls.setup { on_attach = on_attach } -- haskell - lsp.pyright.setup { on_attach = on_attach, - settings = { - pyright = { - disableOrganizeImports = true, -- Using Ruff - }, - python = { - analysis = { - ignore = { '*' }, -- Using Ruff - }, - }, - }, - } - lsp.ruff.setup { on_attach = on_attach } - lsp.svelte.setup { on_attach = on_attach } - lsp.marksman.setup { on_attach = on_attach } - lsp.rust_analyzer.setup { on_attach = on_attach, + vim.lsp.config("rust_analyzer", { settings = { ["rust-analyzer"] = { checkOnSave = true, @@ -110,24 +114,47 @@ return { } } } - } - lsp.tailwindcss.setup { on_attach = on_attach } + }) - lsp.julials.setup { + vim.lsp.config("julials", { on_new_config = function(new_config, _) local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") - if lsp.util.path.is_file(julia) then + if require('lspconfig').util.path.is_file(julia) then vim.notify("running julials") new_config.cmd[1] = julia end - end, - on_attach = on_attach - } + end + }) + + vim.lsp.config("pyright", { + settings = { + pyright = { + disableOrganizeImports = true, -- Using Ruff + }, + python = { + analysis = { + ignore = { '*' }, -- Using Ruff + }, + }, + }, + }) + + vim.lsp.enable({ "lua_ls", + "clangd", + "ts_ls", + "hls", + "ruff", + "svelte", + "marksman", + "tailwindcss", + "rust_analyzer", + "julials", + "pyright" + }) end, }, { 'nvimtools/none-ls.nvim', - event = { "BufReadPre", "BufNewFile" }, config = function() local null_ls = require("null-ls") @@ -147,7 +174,6 @@ return { }) null_ls.setup { - on_attach = on_attach, capabilities = capabilities, sources = { eslint_format,