added language server info output
This commit is contained in:
+158
-38
@@ -33,48 +33,168 @@ vim.pack.add({
|
|||||||
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.lsp.config("lua_ls", {
|
require("lsp.lua_ls")
|
||||||
on_init = function(client)
|
|
||||||
if client.workspace_folders then
|
local function run_healthcheck(section)
|
||||||
local path = client.workspace_folders[1].name
|
local before = {}
|
||||||
if
|
for _, b in ipairs(vim.api.nvim_list_bufs()) do
|
||||||
path ~= vim.fn.stdpath("config")
|
before[b] = true
|
||||||
and (
|
end
|
||||||
vim.uv.fs_stat(path .. "/.luarc.json")
|
|
||||||
or vim.uv.fs_stat(path .. "/.luarc.jsonc")
|
vim.cmd("silent checkhealth " .. section)
|
||||||
)
|
|
||||||
then
|
local after = vim.api.nvim_list_bufs()
|
||||||
-- Path is not neovim's config folder and
|
local health_buf = nil
|
||||||
-- the file .luarc.json or .luarc.jsonc exists
|
|
||||||
-- in the directory -> exit function and skip custom
|
for _, b in ipairs(after) do
|
||||||
-- configuration of the client below
|
if not before[b] then
|
||||||
return
|
health_buf = b
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
|
if not health_buf then
|
||||||
runtime = {
|
return { "Could not capture :checkhealth vim.lsp output" }
|
||||||
-- neovim uses LuaJIT runtime
|
end
|
||||||
version = "LuaJIT",
|
|
||||||
-- find lua modules the same way neovim does
|
-- Read lines
|
||||||
path = {
|
local lines = vim.api.nvim_buf_get_lines(health_buf, 0, -1, false)
|
||||||
"lua/?.lua",
|
|
||||||
"lua/?/init.lua",
|
-- Close the health window
|
||||||
}
|
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||||
},
|
if vim.api.nvim_win_get_buf(win) == health_buf then
|
||||||
-- make the server aware of neovim runtime files
|
vim.api.nvim_win_close(win, true)
|
||||||
workspace = {
|
end
|
||||||
checkThirdParty = false,
|
end
|
||||||
library = {
|
|
||||||
vim.env.VIMRUNTIME,
|
return lines
|
||||||
-- for LSP settings type annotations
|
end
|
||||||
vim.api.nvim_get_runtime_file("lua/lspconfig", false)[1],
|
|
||||||
|
local function get_all_treesitter_languages()
|
||||||
|
local bufnr = 0
|
||||||
|
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
|
||||||
|
if not ok or not parser then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local langs = { parser:lang() }
|
||||||
|
for _, child in ipairs(parser:children()) do
|
||||||
|
table.insert(langs, child:lang())
|
||||||
|
end
|
||||||
|
return langs
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_treesitter_status()
|
||||||
|
local bufnr = 0
|
||||||
|
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
|
||||||
|
|
||||||
|
if not ok or not parser then
|
||||||
|
return {
|
||||||
|
"Treesitter:",
|
||||||
|
" active: no",
|
||||||
|
" parsers: none",
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local langs = get_all_treesitter_languages()
|
||||||
|
return {
|
||||||
|
"Treesitter:",
|
||||||
|
" active: yes",
|
||||||
|
" parsers: " .. table.concat(langs, ", "),
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function show_lsp_details()
|
||||||
|
local popup_buffer = vim.api.nvim_create_buf(false, true)
|
||||||
|
local lsp_clients = vim.lsp.get_clients({ bufnr = 0 })
|
||||||
|
local lines = {}
|
||||||
|
|
||||||
|
-- Treesitter status
|
||||||
|
table.insert(lines, "Treesitter Status")
|
||||||
|
table.insert(lines, "=================")
|
||||||
|
local ts = get_treesitter_status()
|
||||||
|
for _, l in ipairs(ts) do
|
||||||
|
table.insert(lines, l)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(lines, "")
|
||||||
|
if #lsp_clients == 0 then
|
||||||
|
table.insert(lines, "No LSP clients attached.")
|
||||||
|
else
|
||||||
|
table.insert(lines, "Active LSP Clients:")
|
||||||
|
table.insert(lines, "===================")
|
||||||
|
for _, client in ipairs(lsp_clients) do
|
||||||
|
table.insert(lines, "")
|
||||||
|
table.insert(lines, "• " .. client.name)
|
||||||
|
|
||||||
|
-- Root folders
|
||||||
|
local roots = {}
|
||||||
|
if client.workspace_folders then
|
||||||
|
for _, workspace_folder in ipairs(client.workspace_folders) do
|
||||||
|
table.insert(roots, workspace_folder.name or workspace_folder.uri or "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if #roots > 0 then
|
||||||
|
table.insert(lines, " Roots:")
|
||||||
|
for _, root in ipairs(roots) do
|
||||||
|
table.insert(lines, " - " ..root)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
table.insert(lines, " Roots: none")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Capabilities
|
||||||
|
table.insert(lines, " Capabilities:")
|
||||||
|
for capability, _ in pairs(client.server_capabilities or {}) do
|
||||||
|
table.insert(lines, " - " .. capability)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(lines, "")
|
||||||
|
table.insert(lines, "Health Check (vim.lsp):")
|
||||||
|
table.insert(lines, "=======================")
|
||||||
|
local health_lines = run_healthcheck("vim.lsp")
|
||||||
|
for _, l in ipairs(health_lines) do
|
||||||
|
table.insert(lines, " " .. l)
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(lines, "")
|
||||||
|
table.insert(lines, "Health Check (vim.treesitter):")
|
||||||
|
table.insert(lines, "=======================")
|
||||||
|
local health_lines = run_healthcheck("vim.treesitter")
|
||||||
|
for _, l in ipairs(health_lines) do
|
||||||
|
table.insert(lines, " " .. l)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
vim.api.nvim_buf_set_lines(popup_buffer, 0, -1, false, lines)
|
||||||
|
vim.api.nvim_set_option_value("modifiable", false, { buf = popup_buffer })
|
||||||
|
vim.api.nvim_set_option_value("readonly", true, { buf = popup_buffer })
|
||||||
|
local width = math.floor(vim.o.columns * 0.6)
|
||||||
|
local height = math.floor(vim.o.lines * 0.6)
|
||||||
|
local row = math.floor((vim.o.lines - height) / 2)
|
||||||
|
local col = math.floor((vim.o.columns - width) / 2)
|
||||||
|
|
||||||
|
local window = vim.api.nvim_open_win(popup_buffer, true, {
|
||||||
|
relative = "editor",
|
||||||
|
style = "minimal",
|
||||||
|
border = vim.g.ui.popupborder,
|
||||||
|
row = row,
|
||||||
|
col = col,
|
||||||
|
width = width,
|
||||||
|
height = height,
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
settings = {
|
vim.keymap.set("n", "q", function()
|
||||||
Lua = {}
|
if vim.api.nvim_win_is_valid(window) then
|
||||||
}
|
vim.api.nvim_win_close(window, true)
|
||||||
|
end
|
||||||
|
end, { buffer = popup_buffer, nowait = true, desc = "Close Window" })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set("n", "<leader>li", show_lsp_details, {
|
||||||
|
desc = "Show detailed LSP info in a float"
|
||||||
})
|
})
|
||||||
vim.lsp.enable({ "lua_ls" })
|
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣷⣦⣄⡀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠚⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠗⢀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣤⣀
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣶⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⢿⣿⣿⣿⣿⣿⣿⡿⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣶⣤
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠐⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠓⠦⣌⡙⠻⠟⢋⣡⠴⠚⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⠂
|
||||||
|
⠀⠀⠀⠀⢀⣠⣴⣆⡈⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠃⠘⢉⣠⣴⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢁⣰⣦⣄⡀
|
||||||
|
⠀⠀⠐⠾⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠷⠂
|
||||||
|
⠀⢸⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⡇
|
||||||
|
⠀⢸⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⣦⣄⡉⠛⠿⠿⠛⢉⣠⣴⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⡇
|
||||||
|
⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠻⢿⣿⣷⡆⢰⣾⣿⡿⠟⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣌⡙⠃⠘⢋⣡⣴⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⠛⠿⣿⣿⣿⣿⠿⠛⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⣿⣷⣦⣄⡉⢉⣠⣴⣾⣿⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⣿⣿⣿⣿⡇⢸⣿⣿⣿⣿⠿⠛⠉
|
||||||
|
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠿⡇⢸⠿⠛⠉
|
||||||
|
|
||||||
|
__ _ _
|
||||||
|
/ _|___ ___| |_ __ _ ___| | __
|
||||||
|
| ||_ /____/ __| __/ _` |/ __| |/ /
|
||||||
|
| _/ /_____\__ \ || (_| | (__| <
|
||||||
|
|_|/___| |___/\__\__,_|\___|_|\_\
|
||||||
|
|
||||||
|
Neovim v0.12 configuration
|
||||||
|
(C) Frank Zechert 2026
|
||||||
|
]]
|
||||||
|
|
||||||
|
vim.lsp.config("lua_ls", {
|
||||||
|
on_init = function(client)
|
||||||
|
if client.workspace_folders then
|
||||||
|
local path = client.workspace_folders[1].name
|
||||||
|
if
|
||||||
|
path ~= vim.fn.stdpath("config")
|
||||||
|
and (
|
||||||
|
vim.uv.fs_stat(path .. "/.luarc.json")
|
||||||
|
or vim.uv.fs_stat(path .. "/.luarc.jsonc")
|
||||||
|
)
|
||||||
|
then
|
||||||
|
-- Path is not neovim's config folder, or has custom
|
||||||
|
-- lua language server configuration, skip custom client configuration
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
|
||||||
|
runtime = {
|
||||||
|
-- neovim uses LuaJIT runtime
|
||||||
|
version = "LuaJIT",
|
||||||
|
-- find lua modules the same way neovim does
|
||||||
|
path = {
|
||||||
|
"lua/?.lua",
|
||||||
|
"lua/?/init.lua",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
-- make the server aware of neovim runtime files
|
||||||
|
workspace = {
|
||||||
|
checkThirdParty = false,
|
||||||
|
library = {
|
||||||
|
vim.env.VIMRUNTIME,
|
||||||
|
-- for LSP settings type annotations
|
||||||
|
vim.api.nvim_get_runtime_file("lua/lspconfig", false)[1],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
settings = {
|
||||||
|
Lua = {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.enable({ "lua_ls" })
|
||||||
Reference in New Issue
Block a user