mirror of
https://github.com/He4eT/dotfiles.git
synced 2026-05-04 23:47:23 +00:00
nvim: vue: volar + tsserver
This commit is contained in:
parent
ceab2ff63c
commit
78ca7e04d4
1 changed files with 14 additions and 34 deletions
|
|
@ -492,35 +492,9 @@ vim.filetype.add {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local prevent_lsp_conflicts = function(starting_client)
|
|
||||||
-- Note: check autostart parameter in server config.
|
|
||||||
-- https://www.reddit.com/r/neovim/comments/10n795v/comment/j689u7k/
|
|
||||||
local active_clients = vim.lsp.get_active_clients()
|
|
||||||
|
|
||||||
-- Stop 'tsserver' when 'volar' starts
|
|
||||||
if starting_client.name == 'volar' then
|
|
||||||
for _, active_client in pairs(active_clients) do
|
|
||||||
if active_client.name == 'tsserver' then
|
|
||||||
active_client.stop()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Do not start 'tsserver' if 'volar' is running
|
|
||||||
if starting_client.name == 'tsserver' then
|
|
||||||
for _, active_client in pairs(active_clients) do
|
|
||||||
if active_client.name == 'volar' then
|
|
||||||
starting_client.stop()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- [[ LSP settings ]]
|
-- [[ LSP settings ]]
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
-- This function gets run when an LSP connects to a particular buffer.
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
prevent_lsp_conflicts(client)
|
|
||||||
|
|
||||||
local nmap = function(keys, func, desc)
|
local nmap = function(keys, func, desc)
|
||||||
if desc then
|
if desc then
|
||||||
desc = 'LSP: ' .. desc
|
desc = 'LSP: ' .. desc
|
||||||
|
|
@ -576,6 +550,7 @@ local servers = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
volar = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||||
|
|
@ -606,6 +581,18 @@ vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||||
require('lspconfig').tsserver.setup {
|
require('lspconfig').tsserver.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
|
init_options = {
|
||||||
|
plugins = {
|
||||||
|
{
|
||||||
|
name = '@vue/typescript-plugin',
|
||||||
|
location = require('mason-registry')
|
||||||
|
.get_package('vue-language-server')
|
||||||
|
:get_install_path() .. '/node_modules/@vue/language-server',
|
||||||
|
languages = { 'vue' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
||||||
handlers = {
|
handlers = {
|
||||||
-- Usually gets called after a code action
|
-- Usually gets called after a code action
|
||||||
-- like in moving an anonymous function to outer scope
|
-- like in moving an anonymous function to outer scope
|
||||||
|
|
@ -627,13 +614,6 @@ require('lspconfig').tsserver.setup {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
require('lspconfig').volar.setup {
|
|
||||||
autostart = false,
|
|
||||||
on_attach = on_attach,
|
|
||||||
capabilities = capabilities,
|
|
||||||
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' },
|
|
||||||
}
|
|
||||||
|
|
||||||
-- nvim-cmp setup
|
-- nvim-cmp setup
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue