all repos

init.lua @ 84650465a40e45a3c8312185b1ade8f4e85e551d

my nvim config
3 files changed, 19 insertions(+), 14 deletions(-)
feat: add :LspRestart command
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-09-06 18:00:58 +0300
Parent: 34c6c32
M lua/core/lsp.lua

@@ -12,6 +12,11 @@ "ts_ls",

"yamlls", } +vim.api.nvim_create_user_command("LspRestart", function(opts) + vim.lsp.enable(opts.args, false) + vim.lsp.enable(opts.args, true) +end, { nargs = 1, complete = u.lsp.get_clients }) + u.aucmd("LspAttach", { group = u.augroup "lsp", callback = function(args)
M lua/core/utils.lua

@@ -33,5 +33,16 @@ vim.api.nvim_buf_create_user_command(bufnr, name, function()

vim.lsp.buf.execute_command(command) end, {}) end, + + ---get list of lsp servers connected to current buffer + ---@return string[] + get_clients = function() + return vim + .iter(vim.lsp.get_clients { bufnr = 0 }) + :map(function(e) + return (e.name ~= "null-ls" and e.name) or nil + end) + :totable() + end, }, }
M lua/plugins/lualine.lua

@@ -1,3 +1,4 @@

+local u = require "core.utils" local c = { mode = { function()

@@ -9,20 +10,8 @@ diagnostic = { "diagnostics", sources = { "nvim_diagnostic" } },

location = { "location", padding = 1, colored = false }, lsp = { function() - local clients = vim.lsp.get_clients { bufnr = 0 } - local client_names = {} - for _, client in pairs(clients) do - if client.name ~= "null-ls" then - table.insert(client_names, client.name) - end - end - - local client_names_str = table.concat(client_names, ", ") - if #client_names_str == 0 then - return "" - else - return "[" .. client_names_str .. "]" - end + local clients = table.concat(u.lsp.get_clients(), ", ") + return (#clients == 0 and "") or ("[" .. clients .. "]") end, }, }