feat: add lsp handling for non mason

This commit is contained in:
jabuxas 2024-09-18 14:11:51 -03:00
parent 58bbe7790c
commit 34c4b76a1b
3 changed files with 38 additions and 32 deletions

View File

@ -339,14 +339,9 @@ local servers = {
} }
}, },
}, },
marksman = {},
html = { provideFormatter = false }, html = { provideFormatter = false },
cssls = {}, cssls = {},
pyright = {}, pyright = {},
vtsls = {},
texlab = {},
jdtls = { jdtls = {
java = { java = {
@ -388,6 +383,7 @@ vim.list_extend(ensure_installed, {
}) })
require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-tool-installer').setup { ensure_installed = ensure_installed }
require('mason-lspconfig').setup { require('mason-lspconfig').setup {
handlers = { handlers = {
function(server_name) function(server_name)
@ -398,15 +394,14 @@ require('mason-lspconfig').setup {
}, },
} }
local lspconfig = require("lspconfig")
local mason_registry = require('mason-registry') local mason_registry = require('mason-registry')
local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() ..
'/node_modules/@vue/language-server' '/node_modules/@vue/language-server'
lspconfig.tsserver.setup { local manual_servers = {
texlab = {},
tsserver = {
init_options = { init_options = {
plugins = { plugins = {
{ {
@ -417,19 +412,18 @@ lspconfig.tsserver.setup {
}, },
}, },
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
} },
lspconfig.volar.setup { volar = {
init_options = { init_options = {
vue = { vue = {
hybridMode = true, hybridMode = true,
}, },
}, },
}
lspconfig.rust_analyzer.setup { },
capabilities = capabilities,
on_attach = on_attach, rust_analyzer = {
settings = { settings = {
['rust_analyzer'] = { ['rust_analyzer'] = {
cargo = { cargo = {
@ -438,5 +432,12 @@ lspconfig.rust_analyzer.setup {
} }
} }
} }
}
for server_name, config in pairs(manual_servers) do
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
require('lspconfig')[server_name].setup(config)
end
-- this is for my personal config, i cant bother seeing every TJ's default and changing it to my own -- this is for my personal config, i cant bother seeing every TJ's default and changing it to my own
require("jabuxas") require("jabuxas")

View File

@ -18,7 +18,6 @@ keymap.set({ "n", "v" }, "<leader>dd", [["_d]], { desc = "delete" })
keymap.set("i", "<C-c>", "<Esc>") keymap.set("i", "<C-c>", "<Esc>")
keymap.set("n", "Q", "<nop>") keymap.set("n", "Q", "<nop>")
keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmux-sessionizer<CR>")
keymap.set("n", "<leader>f", vim.lsp.buf.format, { desc = "format current buffer" }) keymap.set("n", "<leader>f", vim.lsp.buf.format, { desc = "format current buffer" })
keymap.set("n", keymap.set("n",
"<leader>pv", "<leader>pv",
@ -91,3 +90,7 @@ nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Fo
nmap('<leader>wl', function() nmap('<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders())) print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders') end, '[W]orkspace [L]ist Folders')
vim.keymap.set('c', ';;', function()
return vim.fn.getcmdtype() == ':' and vim.fn.expand('%:h') .. '/' or ';;'
end, { expr = true })

View File

@ -3,6 +3,8 @@ vim.opt.mouse = "a"
vim.opt.nu = true vim.opt.nu = true
vim.opt.relativenumber = true vim.opt.relativenumber = true
vim.opt.cursorline = true
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.softtabstop = 4 vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 4