mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-20 16:15:48 +02:00
enc: add new command
This commit is contained in:
parent
82d6ba2889
commit
5df3f7b2ab
3 changed files with 238 additions and 3 deletions
|
@ -27,7 +27,7 @@
|
|||
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "bef29b653ba71d442816bf56286c2a686210be04" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "f17d02b928a18ab88a50d374be036ab5f499fde4" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
|
||||
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
|
||||
"menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" },
|
||||
|
@ -52,8 +52,8 @@
|
|||
"nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" },
|
||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||
"nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" },
|
||||
"nvim-scrollview": { "branch": "main", "commit": "a313032d62ee630aeac9d5408817f2e834bc9aa9" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "6b5b36659688767fb9f133bb83024ab1466fe5cd" },
|
||||
"nvim-scrollview": { "branch": "main", "commit": "095181bc2adb64af670dae73208871a731f0bb86" },
|
||||
"nvim-tree.lua": { "branch": "master", "commit": "d87b41ca537e2131622d48a6c25ccf2fbe0e5d62" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" },
|
||||
|
|
|
@ -11,6 +11,10 @@ return {
|
|||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "gopls" })
|
||||
-- add run command for current filebuffer
|
||||
vim.api.nvim_create_user_command("RunGo", function()
|
||||
vim.cmd("term go run " .. vim.fn.expand("%"))
|
||||
end, {})
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -124,3 +124,234 @@ vim.api.nvim_create_autocmd("ExitPre", {
|
|||
-- vim.api.nvim_set_keymap("n", "<leader>rg", "<cmd>terminal<cr>gradle run<cr>", { noremap = true, silent = true })
|
||||
-- end,
|
||||
-- })
|
||||
|
||||
-- Extras
|
||||
local function lsp_status()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr })
|
||||
or vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
|
||||
if #clients == 0 then
|
||||
print(" No LSP clients attached")
|
||||
return
|
||||
end
|
||||
|
||||
print(" LSP Status for buffer " .. bufnr .. ":")
|
||||
print("─────────────────────────────────")
|
||||
|
||||
for i, client in ipairs(clients) do
|
||||
print(string.format(" Client %d: %s (ID: %d)", i, client.name, client.id))
|
||||
print(" Root: " .. (client.config.root_dir or "N/A"))
|
||||
print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", "))
|
||||
|
||||
-- Check capabilities
|
||||
local caps = client.server_capabilities
|
||||
local features = {}
|
||||
if caps.completionProvider then
|
||||
table.insert(features, "completion")
|
||||
end
|
||||
if caps.hoverProvider then
|
||||
table.insert(features, "hover")
|
||||
end
|
||||
if caps.definitionProvider then
|
||||
table.insert(features, "definition")
|
||||
end
|
||||
if caps.referencesProvider then
|
||||
table.insert(features, "references")
|
||||
end
|
||||
if caps.renameProvider then
|
||||
table.insert(features, "rename")
|
||||
end
|
||||
if caps.codeActionProvider then
|
||||
table.insert(features, "code_action")
|
||||
end
|
||||
if caps.documentFormattingProvider then
|
||||
table.insert(features, "formatting")
|
||||
end
|
||||
|
||||
print(" Features: " .. table.concat(features, ", "))
|
||||
print("")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LspStatus", lsp_status, { desc = "Show detailed LSP status" })
|
||||
|
||||
local function check_lsp_capabilities()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr })
|
||||
or vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
|
||||
if #clients == 0 then
|
||||
print("No LSP clients attached")
|
||||
return
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
print("Capabilities for " .. client.name .. ":")
|
||||
local caps = client.server_capabilities
|
||||
|
||||
local capability_list = {
|
||||
{ "Completion", caps.completionProvider },
|
||||
{ "Hover", caps.hoverProvider },
|
||||
{ "Signature Help", caps.signatureHelpProvider },
|
||||
{ "Go to Definition", caps.definitionProvider },
|
||||
{ "Go to Declaration", caps.declarationProvider },
|
||||
{ "Go to Implementation", caps.implementationProvider },
|
||||
{ "Go to Type Definition", caps.typeDefinitionProvider },
|
||||
{ "Find References", caps.referencesProvider },
|
||||
{ "Document Highlight", caps.documentHighlightProvider },
|
||||
{ "Document Symbol", caps.documentSymbolProvider },
|
||||
{ "Workspace Symbol", caps.workspaceSymbolProvider },
|
||||
{ "Code Action", caps.codeActionProvider },
|
||||
{ "Code Lens", caps.codeLensProvider },
|
||||
{ "Document Formatting", caps.documentFormattingProvider },
|
||||
{ "Document Range Formatting", caps.documentRangeFormattingProvider },
|
||||
{ "Rename", caps.renameProvider },
|
||||
{ "Folding Range", caps.foldingRangeProvider },
|
||||
{ "Selection Range", caps.selectionRangeProvider },
|
||||
}
|
||||
|
||||
for _, cap in ipairs(capability_list) do
|
||||
local status = cap[2] and "✓" or "✗"
|
||||
print(string.format(" %s %s", status, cap[1]))
|
||||
end
|
||||
print("")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LspCapabilities", check_lsp_capabilities, { desc = "Show LSP capabilities" })
|
||||
|
||||
local function lsp_diagnostics_info()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local diagnostics = vim.diagnostic.get(bufnr)
|
||||
|
||||
local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 }
|
||||
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
local severity = vim.diagnostic.severity[diagnostic.severity]
|
||||
counts[severity] = counts[severity] + 1
|
||||
end
|
||||
|
||||
print(" Diagnostics for current buffer:")
|
||||
print(" Errors: " .. counts.ERROR)
|
||||
print(" Warnings: " .. counts.WARN)
|
||||
print(" Info: " .. counts.INFO)
|
||||
print(" Hints: " .. counts.HINT)
|
||||
print(" Total: " .. #diagnostics)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("LspDiagnostics", lsp_diagnostics_info, { desc = "Show LSP diagnostics count" })
|
||||
|
||||
local function lsp_info()
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local clients = vim.lsp.get_clients and vim.lsp.get_clients({ bufnr = bufnr })
|
||||
or vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
|
||||
print("═══════════════════════════════════")
|
||||
print(" LSP INFORMATION ")
|
||||
print("═══════════════════════════════════")
|
||||
print("")
|
||||
|
||||
-- Basic info
|
||||
print(" Language client log: " .. vim.lsp.get_log_path())
|
||||
print(" Detected filetype: " .. vim.bo.filetype)
|
||||
print(" Buffer: " .. bufnr)
|
||||
print(" Root directory: " .. (vim.fn.getcwd() or "N/A"))
|
||||
print("")
|
||||
|
||||
if #clients == 0 then
|
||||
print(" No LSP clients attached to buffer " .. bufnr)
|
||||
print("")
|
||||
print("Possible reasons:")
|
||||
print(" • No language server installed for " .. vim.bo.filetype)
|
||||
print(" • Language server not configured")
|
||||
print(" • Not in a project root directory")
|
||||
print(" • File type not recognized")
|
||||
return
|
||||
end
|
||||
|
||||
print(" LSP clients attached to buffer " .. bufnr .. ":")
|
||||
print("─────────────────────────────────")
|
||||
|
||||
for i, client in ipairs(clients) do
|
||||
print(string.format(" Client %d: %s", i, client.name))
|
||||
print(" ID: " .. client.id)
|
||||
print(" Root dir: " .. (client.config.root_dir or "Not set"))
|
||||
print(" Command: " .. table.concat(client.config.cmd or {}, " "))
|
||||
print(" Filetypes: " .. table.concat(client.config.filetypes or {}, ", "))
|
||||
|
||||
-- Server status
|
||||
if client.is_stopped() then
|
||||
print(" Status: Stopped")
|
||||
else
|
||||
print(" Status: Running")
|
||||
end
|
||||
|
||||
-- Workspace folders
|
||||
if client.workspace_folders and #client.workspace_folders > 0 then
|
||||
print(" Workspace folders:")
|
||||
for _, folder in ipairs(client.workspace_folders) do
|
||||
print(" • " .. folder.name)
|
||||
end
|
||||
end
|
||||
|
||||
-- Attached buffers count
|
||||
local attached_buffers = {}
|
||||
for buf, _ in pairs(client.attached_buffers or {}) do
|
||||
table.insert(attached_buffers, buf)
|
||||
end
|
||||
print(" Attached buffers: " .. #attached_buffers)
|
||||
|
||||
-- Key capabilities
|
||||
local caps = client.server_capabilities
|
||||
local key_features = {}
|
||||
if caps.completionProvider then
|
||||
table.insert(key_features, "completion")
|
||||
end
|
||||
if caps.hoverProvider then
|
||||
table.insert(key_features, "hover")
|
||||
end
|
||||
if caps.definitionProvider then
|
||||
table.insert(key_features, "definition")
|
||||
end
|
||||
if caps.documentFormattingProvider then
|
||||
table.insert(key_features, "formatting")
|
||||
end
|
||||
if caps.codeActionProvider then
|
||||
table.insert(key_features, "code_action")
|
||||
end
|
||||
|
||||
if #key_features > 0 then
|
||||
print(" Key features: " .. table.concat(key_features, ", "))
|
||||
end
|
||||
|
||||
print("")
|
||||
end
|
||||
|
||||
-- Diagnostics summary
|
||||
local diagnostics = vim.diagnostic.get(bufnr)
|
||||
if #diagnostics > 0 then
|
||||
print(" Diagnostics Summary:")
|
||||
local counts = { ERROR = 0, WARN = 0, INFO = 0, HINT = 0 }
|
||||
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
local severity = vim.diagnostic.severity[diagnostic.severity]
|
||||
counts[severity] = counts[severity] + 1
|
||||
end
|
||||
|
||||
print(" Errors: " .. counts.ERROR)
|
||||
print(" Warnings: " .. counts.WARN)
|
||||
print(" Info: " .. counts.INFO)
|
||||
print(" Hints: " .. counts.HINT)
|
||||
print(" Total: " .. #diagnostics)
|
||||
else
|
||||
print(" No diagnostics")
|
||||
end
|
||||
|
||||
print("")
|
||||
print("Use :LspLog to view detailed logs")
|
||||
print("Use :LspCapabilities for full capability list")
|
||||
end
|
||||
|
||||
-- Create command
|
||||
vim.api.nvim_create_user_command("LspInfo2", lsp_info, { desc = "Show comprehensive LSP information" })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue