my neovim config, who would've thought

feat: add :LspRestart command

olexsmir.xyz 84650465 34c6c32b

verified
Changed files
+19 -14
lua
+5
lua/core/lsp.lua
··· 12 12 "yamlls", 13 13 } 14 14 15 + vim.api.nvim_create_user_command("LspRestart", function(opts) 16 + vim.lsp.enable(opts.args, false) 17 + vim.lsp.enable(opts.args, true) 18 + end, { nargs = 1, complete = u.lsp.get_clients }) 19 + 15 20 u.aucmd("LspAttach", { 16 21 group = u.augroup "lsp", 17 22 callback = function(args)
+11
lua/core/utils.lua
··· 33 33 vim.lsp.buf.execute_command(command) 34 34 end, {}) 35 35 end, 36 + 37 + ---get list of lsp servers connected to current buffer 38 + ---@return string[] 39 + get_clients = function() 40 + return vim 41 + .iter(vim.lsp.get_clients { bufnr = 0 }) 42 + :map(function(e) 43 + return (e.name ~= "null-ls" and e.name) or nil 44 + end) 45 + :totable() 46 + end, 36 47 }, 37 48 }
+3 -14
lua/plugins/lualine.lua
··· 1 + local u = require "core.utils" 1 2 local c = { 2 3 mode = { 3 4 function() ··· 9 10 location = { "location", padding = 1, colored = false }, 10 11 lsp = { 11 12 function() 12 - local clients = vim.lsp.get_clients { bufnr = 0 } 13 - local client_names = {} 14 - for _, client in pairs(clients) do 15 - if client.name ~= "null-ls" then 16 - table.insert(client_names, client.name) 17 - end 18 - end 19 - 20 - local client_names_str = table.concat(client_names, ", ") 21 - if #client_names_str == 0 then 22 - return "" 23 - else 24 - return "[" .. client_names_str .. "]" 25 - end 13 + local clients = table.concat(u.lsp.get_clients(), ", ") 14 + return (#clients == 0 and "") or ("[" .. clients .. "]") 26 15 end, 27 16 }, 28 17 }