From 34c4b76a1b80446aa2e155261bda1ec3e6ad7797 Mon Sep 17 00:00:00 2001 From: jabuxas Date: Wed, 18 Sep 2024 14:11:51 -0300 Subject: [PATCH] feat: add lsp handling for non mason --- init.lua | 63 ++++++++++++++++++++++--------------------- lua/jabuxas/remap.lua | 5 +++- lua/jabuxas/set.lua | 2 ++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/init.lua b/init.lua index fd0a2ad..bbdcb27 100644 --- a/init.lua +++ b/init.lua @@ -339,14 +339,9 @@ local servers = { } }, }, - marksman = {}, html = { provideFormatter = false }, cssls = {}, pyright = {}, - vtsls = {}, - - - texlab = {}, jdtls = { java = { @@ -388,6 +383,7 @@ vim.list_extend(ensure_installed, { }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } + require('mason-lspconfig').setup { handlers = { function(server_name) @@ -398,45 +394,50 @@ require('mason-lspconfig').setup { }, } - - -local lspconfig = require("lspconfig") - local mason_registry = require('mason-registry') local vue_language_server_path = mason_registry.get_package('vue-language-server'):get_install_path() .. '/node_modules/@vue/language-server' -lspconfig.tsserver.setup { - init_options = { - plugins = { - { - name = '@vue/typescript-plugin', - location = vue_language_server_path, - languages = { 'vue' }, +local manual_servers = { + texlab = {}, + + tsserver = { + init_options = { + plugins = { + { + name = '@vue/typescript-plugin', + location = vue_language_server_path, + languages = { 'vue' }, + }, }, }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, }, - filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, -} -lspconfig.volar.setup { - init_options = { - vue = { - hybridMode = true, + volar = { + init_options = { + vue = { + hybridMode = true, + }, }, - }, -} -lspconfig.rust_analyzer.setup { - capabilities = capabilities, - on_attach = on_attach, - settings = { - ['rust_analyzer'] = { - cargo = { - allFeatures = true, + }, + + rust_analyzer = { + settings = { + ['rust_analyzer'] = { + cargo = { + allFeatures = true, + } } } } } + +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 require("jabuxas") diff --git a/lua/jabuxas/remap.lua b/lua/jabuxas/remap.lua index 483c00d..a9a1074 100644 --- a/lua/jabuxas/remap.lua +++ b/lua/jabuxas/remap.lua @@ -18,7 +18,6 @@ keymap.set({ "n", "v" }, "dd", [["_d]], { desc = "delete" }) keymap.set("i", "", "") keymap.set("n", "Q", "") -keymap.set("n", "", "silent !tmux neww tmux-sessionizer") keymap.set("n", "f", vim.lsp.buf.format, { desc = "format current buffer" }) keymap.set("n", "pv", @@ -91,3 +90,7 @@ nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Fo nmap('wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_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 }) diff --git a/lua/jabuxas/set.lua b/lua/jabuxas/set.lua index 0d37120..4eb82be 100644 --- a/lua/jabuxas/set.lua +++ b/lua/jabuxas/set.lua @@ -3,6 +3,8 @@ vim.opt.mouse = "a" vim.opt.nu = true vim.opt.relativenumber = true +vim.opt.cursorline = true + vim.opt.tabstop = 4 vim.opt.softtabstop = 4 vim.opt.shiftwidth = 4