feat: add lsp configuration

This commit is contained in:
Ian
2026-07-12 23:58:37 +02:00
parent 559319f6af
commit 85a216b44e
6 changed files with 88 additions and 40 deletions
+27 -27
View File
@@ -1,44 +1,44 @@
local M = {} local M = {}
cmdsList = nil CmdsList = nil
function M.checkCommand(cmd, desc) function M.checkCommand(cmd, desc)
local toRun = "" local toRun = ""
if IS_UNIX then if IS_UNIX then
toRun = "command -v " .. cmd toRun = "command -v " .. cmd
else else
toRun = "where " .. cmd toRun = "where " .. cmd
end end
local p = io.popen(toRun) local p = io.popen(toRun)
local output = p:read("*l") local output = p:read("*l")
p:close() p:close()
if output == nil and desc ~= nil and desc ~= "" then if output == nil and desc ~= nil and desc ~= "" then
vim.api.nvim_echo({ { "" .. cmd .. " [" .. desc .. "] - not found!", "DiagnosticError" } }, true, {}) vim.api.nvim_echo({ { "" .. cmd .. " [" .. desc .. "] - not found!", "DiagnosticError" } }, true, {})
elseif output == nil then elseif output == nil then
vim.api.nvim_echo({ { "" .. cmd .. " not found!", "DiagnosticError" } }, true, {}) vim.api.nvim_echo({ { "" .. cmd .. " not found!", "DiagnosticError" } }, true, {})
else else
vim.api.nvim_echo({ { "" .. cmd, "DiagnosticOk" } }, true, {}) vim.api.nvim_echo({ { "" .. cmd, "DiagnosticOk" } }, true, {})
end end
end end
function M.run() function M.run()
if cmdsList == nil or next(cmdsList) == nil then if CmdsList == nil or next(CmdsList) == nil then
vim.api.nvim_echo({{"Dependencies list passed is null or empty, nothing to check", "DiagnosticWarn"}}, true, {}) vim.api.nvim_echo({ { "Dependencies list passed is null or empty, nothing to check", "DiagnosticWarn" } }, true, {})
return return
end end
print("Check installed system commands:") print("Check installed system commands:")
for i, cmd in ipairs(cmdsList) do for _, cmd in ipairs(CmdsList) do
M.checkCommand(cmd.cmd, cmd.desc) M.checkCommand(cmd.cmd, cmd.desc)
end end
end end
function M.setup(cmds) function M.setup(cmds)
IS_UNIX = package.config:sub(1, 1) ~= "\\" IS_UNIX = package.config:sub(1, 1) ~= "\\"
cmdsList = cmds CmdsList = cmds
end end
return M return M
+2 -2
View File
@@ -1,4 +1,4 @@
function run() function Run()
local dep = require("check_dependencies") local dep = require("check_dependencies")
dep.setup({ dep.setup({
@@ -20,4 +20,4 @@ function run()
dep.run() dep.run()
end end
vim.api.nvim_create_user_command("DependenciesCheck", run, {}) vim.api.nvim_create_user_command("DependenciesCheck", Run, {})
+13 -11
View File
@@ -1,13 +1,15 @@
require('config.settings') require("config.settings")
require('config.keybinds') require("config.keybinds")
require('config.pack') require("config.pack")
require("config.lsp")
require('config.theme') require("config.theme")
require('config.neogit') require("config.neogit")
require('config.oil') require("config.oil")
require('config.autopairs') require("config.autopairs")
require('config.fzf') require("config.fzf")
require('config.indent_blank_line') require("config.indent_blank_line")
require('config.conform') require("config.conform")
require("config.check_dependencies")
require('config.check_dependencies')
+8
View File
@@ -54,3 +54,11 @@ end, {
}) })
bind("n", "<leader><C-M-l>", "<cmd>FormatConform<cr>") bind("n", "<leader><C-M-l>", "<cmd>FormatConform<cr>")
-- Lsp
bind("n", "<leader>e", vim.diagnostic.open_float)
bind("n", "<leader>gl", vim.diagnostic.setloclist)
bind("n", "<leader>gf", vim.diagnostic.setqflist)
bind("n", "<leader>f", vim.lsp.buf.format)
bind("n", "K", vim.lsp.buf.hover)
bind("n", "<leader>k", vim.lsp.buf.signature_help)
+24
View File
@@ -0,0 +1,24 @@
| Set | Mapping | Function | Neovim Function | Brief Description |
| --- | ------------- | ---------------------------- | --------------------------------------- | --------------------------------------------------------------------------- |
| y | `gd` | Go to Definition | `vim.lsp.buf.definition()` | Jump to the symbol's definition. |
| y | `gD` | Go to Declaration | `vim.lsp.buf.declaration()` | Jump to the symbol's declaration. |
| y | `K` | Hover Documentation | `vim.lsp.buf.hover()` | Show documentation and type information for the symbol under the cursor. |
| y | `<leader>k` | Signature Help | `vim.lsp.buf.signature_help()` | Display the current function signature and parameter information. |
| y | `grr` | Find References | `vim.lsp.buf.references()` | List all references to the symbol across the project. |
| y | `gri` | Go to Implementation | `vim.lsp.buf.implementation()` | Jump to the implementation(s) of the symbol. |
| y | `grt` | Go to Type Definition | `vim.lsp.buf.type_definition()` | Jump to the definition of the symbol's type. |
| y | `grn` | Rename Symbol | `vim.lsp.buf.rename()` | Rename the symbol and update all references. |
| y | `gra` | Code Actions | `vim.lsp.buf.code_action()` | Show available quick fixes and refactoring actions. |
| ? | `gO` | Document Symbols | `vim.lsp.buf.document_symbol()` | List all symbols (functions, classes, variables, etc.) in the current file. |
| y | `[d` | Previous Diagnostic | `vim.diagnostic.goto_prev()` | Jump to the previous diagnostic (error, warning, hint, or info). |
| y | `]d` | Next Diagnostic | `vim.diagnostic.goto_next()` | Jump to the next diagnostic. |
| y | `<leader>e` | Diagnostic Float | `vim.diagnostic.open_float()` | Show diagnostic details in a floating window. |
| y | `<leader>gl` | Diagnostics to Location List | `vim.diagnostic.setloclist()` | Populate the location list with diagnostics from the current buffer. |
| y | `<leader>f` | Format Buffer | `vim.lsp.buf.format()` | Format the current buffer using the LSP server. |
| n | `<leader>wa` | Add Workspace Folder | `vim.lsp.buf.add_workspace_folder()` | Add a folder to the current LSP workspace. |
| n | `<leader>wr` | Remove Workspace Folder | `vim.lsp.buf.remove_workspace_folder()` | Remove a folder from the current LSP workspace. |
| n | `<leader>wl` | List Workspace Folders | `vim.lsp.buf.list_workspace_folders()` | List all folders in the current LSP workspace. |
| n | `<leader>cl` | Run CodeLens | `vim.lsp.codelens.run()` | Execute the CodeLens action at the current cursor position. |
| n | `<leader>cr` | Refresh CodeLens | `vim.lsp.codelens.refresh()` | Refresh available CodeLens actions in the buffer. |
| n | `<leader>th` | Toggle Inlay Hints | `vim.lsp.inlay_hint.enable()` | Enable or disable inline type and parameter hints. |
+14
View File
@@ -0,0 +1,14 @@
vim.lsp.config["lua_lsp"] = {
cmd = { "lua-language-server" },
filetypes = { "lua" },
root_markers = { { ".luarc.json", ".luarc.jsonc" }, ".git" },
settings = {
Lua = {
runtime = {
version = "LuaJIT",
},
},
},
}
vim.lsp.enable('lua_lsp')