fix lsp stuff

This commit is contained in:
2025-07-29 00:36:03 +02:00
parent 0d2fe89b90
commit 3b0e43f2f9
4 changed files with 48 additions and 30 deletions

View File

@@ -14,5 +14,8 @@ vim.api.nvim_create_autocmd({ "TextChanged" }, {
-- This updates the LSP diagnostics
vim.cmd("startinsert")
vim.cmd("stopinsert")
local pos = vim.api.nvim_win_get_cursor(0)
vim.api.nvim_win_set_cursor(0, pos)
end,
})

View File

@@ -61,7 +61,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
vim.keymap.set("n", "]d", function()
vim.diagnostic.jump({ count = -1 })
end, lsp_opts)
vim.keymap.set("n", "<leader>vca", function()
vim.keymap.set("n", "<c-m>", function()
vim.lsp.buf.code_action()
end, lsp_opts)
vim.keymap.set("n", "<leader>vrr", function()
@@ -73,7 +73,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, lsp_opts)
end
end,
})
vim.lsp.config.tailwindcss = {
@@ -121,13 +121,15 @@ vim.lsp.config.vtsls = {
name = "typescript-svelte-plugin",
location = vim.fn.getcwd() .. "/node_modules/typescript-svelte-plugin",
enableForWorkspaceTypeScriptVersions = true,
}, {
name = "@vue/typescript-plugin",
location = vim.fn.expand "$MASON/packages" ..
"/vue-language-server" .. "/node_modules/@vue/language-server",
languages = { "vue" },
configNamespace = 'typescript',
},
},
{
name = "@vue/typescript-plugin",
location = vim.fn.expand("$MASON/packages")
.. "/vue-language-server"
.. "/node_modules/@vue/language-server",
languages = { "vue" },
configNamespace = "typescript",
},
},
},
},
@@ -152,11 +154,13 @@ vim.lsp.config.vtsls = {
vim.lsp.config.vue_ls = {
on_init = function(client)
client.handlers['tsserver/request'] = function(_, result, context)
local clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = 'vtsls' })
client.handlers["tsserver/request"] = function(_, result, context)
local clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = "vtsls" })
if #clients == 0 then
vim.notify('Could not found `vtsls` lsp client, vue_lsp would not work without it.',
vim.log.levels.ERROR)
vim.notify(
"Could not found `vtsls` lsp client, vue_lsp would not work without it.",
vim.log.levels.ERROR
)
return
end
local ts_client = clients[1]
@@ -164,8 +168,8 @@ vim.lsp.config.vue_ls = {
local param = unpack(result)
local id, command, payload = unpack(param)
ts_client:exec_cmd({
title = 'vue_request_forward', -- You can give title anything as it's used to represent a command in the UI, `:h Client:exec_cmd`
command = 'typescript.tsserverRequest',
title = "vue_request_forward", -- You can give title anything as it's used to represent a command in the UI, `:h Client:exec_cmd`
command = "typescript.tsserverRequest",
arguments = {
command,
payload,
@@ -173,7 +177,7 @@ vim.lsp.config.vue_ls = {
}, { bufnr = context.bufnr }, function(_, r)
local response_data = { { id, r.body } }
---@diagnostic disable-next-line: param-type-mismatch
client:notify('tsserver/response', response_data)
client:notify("tsserver/response", response_data)
end)
end
end,
@@ -193,5 +197,15 @@ vim.lsp.config.svelte = {
client.notify(client, "$/onDidChangeTsOrJsFile", { uri = ctx.match })
end,
})
end
end,
}
vim.lsp.config.cssls = {
settings = {
css = {
lint = {
unknownAtRules = "ignore",
},
},
},
}