Change nvim lspconfig to work with mason and vue
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
cursor {
|
||||
xcursor-theme "Banana-Blue"
|
||||
xcursor-size 30
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// This config is in the KDL format: https://kdl.dev
|
||||
// "/-" comments out the following node.
|
||||
// Check the wiki for a full description of the configuration:
|
||||
|
||||
@@ -32,7 +32,8 @@ programs.neovim.plugins = [
|
||||
# ".config/nvim/lua/plugins/coq.lua".source = ./lua/plugins/coq.lua;
|
||||
".config/nvim/lua/plugins/blink-cmp.lua".source = ./lua/plugins/blink-cmp.lua;
|
||||
".config/nvim/lua/plugins/lsp.lua".source = ./lua/plugins/lsp.lua;
|
||||
# ".config/nvim/lua/plugins/mason.lua".source = ./lua/plugins/mason.lua;
|
||||
".config/nvim/lua/plugins/mason.lua".source = ./lua/plugins/mason.lua;
|
||||
".config/nvim/lua/plugins/mason-lspconfig.lua".source = ./lua/plugins/mason-lspconfig.lua;
|
||||
# ".config/nvim/lua/plugins/treesitter.lua".source = ./lua/plugins/treesitter.lua;
|
||||
".config/nvim/lua/plugins/catppuccin.lua".source = ./lua/plugins/catppuccin.lua;
|
||||
".config/nvim/lua/plugins/telescope.lua".source = ./lua/plugins/telescope.lua;
|
||||
|
||||
@@ -145,7 +145,7 @@ vim.keymap.set("n", "<leader>tt", ":ToggleTerm direction=tab size=50 <CR>", { de
|
||||
vim.keymap.set("n", "<leader>tv", ":ToggleTerm direction=vertical <CR>", { desc = "Open terminal vertical" })
|
||||
vim.keymap.set("n", "<leader>ts", ":ToggleTerm direction=vertical <CR>", { desc = "select open terminal" })
|
||||
-- file explorer binds (nvim-tree)
|
||||
vim.keymap.set("n", "<leader>fe", ":NvimTreeToggle <CR>", { desc = "select open terminal" })
|
||||
vim.keymap.set("n", "<leader>fe", ":NvimTreeToggle <CR>", { desc = "Toggle nvim tree" })
|
||||
-- code actions
|
||||
vim.keymap.set("n", "<leader>ca", function()
|
||||
require("tiny-code-action").code_action()
|
||||
@@ -154,3 +154,5 @@ end, { desc = "Show code actions", noremap = true, silent = true })
|
||||
-- disable annoying inline type things
|
||||
vim.lsp.inlay_hint.enable(false)
|
||||
vim.diagnostic.config({virtual_text = false})
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +1,69 @@
|
||||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
dependencies = { 'saghen/blink.cmp' },
|
||||
config = function(_,_)
|
||||
|
||||
-- example using `opts` for defining servers
|
||||
opts = {
|
||||
servers = {
|
||||
lua_ls = {},
|
||||
nil_ls = {},
|
||||
vue_ls = {},
|
||||
-- rust_analyzer = {},
|
||||
-- gopls = {},
|
||||
local vue_language_server_path = vim.fn.expand '$MASON/packages' .. '/vue-language-server' .. '/node_modules/@vue/language-server'
|
||||
|
||||
local tsserver_filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }
|
||||
local vue_plugin = {
|
||||
name = '@vue/typescript-plugin',
|
||||
location = vue_language_server_path,
|
||||
languages = { 'vue' },
|
||||
configNamespace = 'typescript',
|
||||
}
|
||||
},
|
||||
config = function(_, opts)
|
||||
local lspconfig = require('lspconfig')
|
||||
for server, config in pairs(opts.servers) do
|
||||
-- passing config.capabilities to blink.cmp merges with the capabilities in your
|
||||
-- `opts[server].capabilities, if you've defined it
|
||||
config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||
lspconfig[server].setup(config)
|
||||
end
|
||||
local vtsls_config = {
|
||||
settings = {
|
||||
vtsls = {
|
||||
tsserver = {
|
||||
globalPlugins = {
|
||||
vue_plugin,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filetypes = tsserver_filetypes,
|
||||
}
|
||||
|
||||
local ts_ls_config = {
|
||||
init_options = {
|
||||
plugins = {
|
||||
vue_plugin,
|
||||
},
|
||||
},
|
||||
filetypes = tsserver_filetypes,
|
||||
}
|
||||
|
||||
-- If you are on most recent `nvim-lspconfig`
|
||||
local vue_ls_config = {}
|
||||
-- nvim 0.11 or above
|
||||
vim.lsp.config('vtsls', vtsls_config)
|
||||
vim.lsp.config('vue_ls', vue_ls_config)
|
||||
vim.lsp.config('lua_ls', {})
|
||||
vim.lsp.enable({'vtsls', 'vue_ls', 'lua_ls'})
|
||||
end
|
||||
|
||||
-- -- example calling setup directly for each LSP
|
||||
-- config = function()
|
||||
-- local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
-- local lspconfig = require('lspconfig')
|
||||
--
|
||||
-- lspconfig['lua_ls'].setup({ capabilities = capabilities })
|
||||
-- end
|
||||
|
||||
-- opts = {
|
||||
-- servers = {
|
||||
-- lua_ls = {},
|
||||
-- nil_ls = {},
|
||||
-- vstls = {},
|
||||
-- vue_ls = {},
|
||||
-- -- rust_analyzer = {},
|
||||
-- -- gopls = {},
|
||||
-- }
|
||||
-- },
|
||||
-- config = function(_, opts)
|
||||
-- for server, config in pairs(opts.servers) do
|
||||
-- config.capabilities = require('blink.cmp').get_lsp_capabilities(config.capabilities)
|
||||
--
|
||||
-- -- Verwende `vim.lsp.config` um die Konfiguration anzupassen
|
||||
-- vim.lsp.config(server, config)
|
||||
--
|
||||
-- -- Aktiviere die Konfiguration
|
||||
-- vim.lsp.enable(server)
|
||||
-- end
|
||||
-- end
|
||||
}
|
||||
|
||||
|
||||
8
packages/nvim/lua/plugins/mason-lspconfig.lua
Normal file
8
packages/nvim/lua/plugins/mason-lspconfig.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
return {
|
||||
"mason-org/mason-lspconfig.nvim",
|
||||
opts = {},
|
||||
dependencies = {
|
||||
{ "mason-org/mason.nvim", opts = {} },
|
||||
"neovim/nvim-lspconfig",
|
||||
},
|
||||
}
|
||||
@@ -1,37 +1,46 @@
|
||||
return {
|
||||
|
||||
"williamboman/mason.nvim",
|
||||
cmd = "Mason",
|
||||
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
|
||||
build = ":MasonUpdate",
|
||||
opts_extend = { "ensure_installed" },
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shfmt",
|
||||
},
|
||||
},
|
||||
---@param opts MasonSettings | {ensure_installed: string[]}
|
||||
config = function(_, opts)
|
||||
require("mason").setup(opts)
|
||||
local mr = require("mason-registry")
|
||||
mr:on("package:install:success", function()
|
||||
vim.defer_fn(function()
|
||||
-- trigger FileType event to possibly load this newly installed LSP server
|
||||
require("lazy.core.handler.event").trigger({
|
||||
event = "FileType",
|
||||
buf = vim.api.nvim_get_current_buf(),
|
||||
})
|
||||
end, 100)
|
||||
end)
|
||||
|
||||
mr.refresh(function()
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end,
|
||||
"mason-org/mason.nvim",
|
||||
config = function ()
|
||||
require("mason").setup()
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
-- return {
|
||||
--
|
||||
-- "williamboman/mason.nvim",
|
||||
-- cmd = "Mason",
|
||||
-- keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
|
||||
-- build = ":MasonUpdate",
|
||||
-- opts_extend = { "ensure_installed" },
|
||||
-- opts = {
|
||||
-- ensure_installed = {
|
||||
-- -- "stylua",
|
||||
-- -- "shfmt",
|
||||
-- },
|
||||
-- },
|
||||
-- ---@param opts MasonSettings | {ensure_installed: string[]}
|
||||
-- config = function(_, opts)
|
||||
-- require("mason").setup(opts)
|
||||
-- local mr = require("mason-registry")
|
||||
-- mr:on("package:install:success", function()
|
||||
-- vim.defer_fn(function()
|
||||
-- -- trigger FileType event to possibly load this newly installed LSP server
|
||||
-- require("lazy.core.handler.event").trigger({
|
||||
-- event = "FileType",
|
||||
-- buf = vim.api.nvim_get_current_buf(),
|
||||
-- })
|
||||
-- end, 100)
|
||||
-- end)
|
||||
--
|
||||
-- mr.refresh(function()
|
||||
-- for _, tool in ipairs(opts.ensure_installed) do
|
||||
-- local p = mr.get_package(tool)
|
||||
-- if not p:is_installed() then
|
||||
-- p:install()
|
||||
-- end
|
||||
-- end
|
||||
-- end)
|
||||
-- end,
|
||||
-- }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user