Skip to content

Commit

Permalink
📝 lsp updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nimueller committed Feb 4, 2024
1 parent 7cf99ae commit 9227614
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 67 deletions.
134 changes: 68 additions & 66 deletions config/nvim/lua/settings/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,91 +1,93 @@
-- LSP servers
local servers = {
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
nil_ls = {},
statix = {},
biome = {},
tsserver = {},
jsonls = {},
cssls = {},
eslint = {},
bashls = {},
texlab = {},
ltex = {},
lua_ls = {
Lua = {
workspace = { checkThirdParty = false },
telemetry = { enable = false },
},
},
nil_ls = {},
statix = {},
biome = {},
tsserver = {},
jsonls = {},
cssls = {},
eslint = {},
bashls = {},
texlab = {},
ltex = {},

lemminx = {},
jdtls = {},
kotlin_language_server = {}
lemminx = {},
jdtls = {},
kotlin_language_server = {},
}

local augroup = vim.api.nvim_create_augroup("LspFormatting", {})

local on_attach = function(client, bufnr)
local nmap = function(keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
local nmap = function(keys, func, desc)
if desc then
desc = "LSP: " .. desc
end

vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
end
vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc })
end

nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
nmap('<leader>cf', vim.lsp.buf.format, '[C]ode [F]ormat')
nmap('<leader>cr', vim.lsp.buf.rename, '[C]ode [R]ename')
nmap("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction")
nmap("<leader>cf", vim.lsp.buf.format, "[C]ode [F]ormat")
nmap("<leader>cr", vim.lsp.buf.rename, "[C]ode [R]ename")

nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
nmap("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
nmap("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")

-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-p>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- See `:help K` for why this keymap
nmap("K", vim.lsp.buf.hover, "Hover Documentation")
nmap("<C-p>", vim.lsp.buf.signature_help, "Signature Documentation")

-- Lesser used LSP functionality
nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Lesser used LSP functionality
nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition")
nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
nmap("<leader>wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder")
nmap("<leader>wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder")
nmap("<leader>wl", function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, "[W]orkspace [L]ist Folders")

if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end

-- Setup neovim lua configuration
require('neodev').setup()
require("neodev").setup()

local lsp = require 'lspconfig'
local lsp = require("lspconfig")

for server_name, config in pairs(servers) do
lsp[server_name].setup {
on_attach = on_attach,
settings = config,
}
lsp[server_name].setup({
on_attach = on_attach,
settings = config,
})
end

local null_ls = require 'null-ls'
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.luacheck,
null_ls.builtins.formatting.stylua,
null_ls.builtins.diagnostics.ktlint,
null_ls.builtins.formatting.ktlint
}
sources = {
null_ls.builtins.diagnostics.luacheck,
null_ls.builtins.diagnostics.tidy,
null_ls.builtins.diagnostics.ktlint,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.ktlint,
null_ls.builtins.formatting.tidy,
},
})

local telescope = require 'telescope'
telescope.load_extension('ui-select')
local telescope = require("telescope")
telescope.load_extension("ui-select")
3 changes: 2 additions & 1 deletion home-manager/headless/neovim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
nil
statix

# XML
# XML/HTML
lemminx
html-tidy

# Kotlin/Java
jdt-language-server
Expand Down

0 comments on commit 9227614

Please sign in to comment.