mirror of https://github.com/wlcx/home.git
vim: add volar vuejs lsp stuff
This commit is contained in:
parent
883a824e31
commit
a1274f54ef
|
@ -9,7 +9,7 @@
|
||||||
./macs.nix
|
./macs.nix
|
||||||
./rust.nix
|
./rust.nix
|
||||||
./vim.nix
|
./vim.nix
|
||||||
./vim-dev.nix
|
./vim-dev
|
||||||
./passwords.nix
|
./passwords.nix
|
||||||
./gpg.nix
|
./gpg.nix
|
||||||
];
|
];
|
||||||
|
|
|
@ -24,12 +24,13 @@ in {
|
||||||
vim-vue-plugin
|
vim-vue-plugin
|
||||||
kotlin-vim
|
kotlin-vim
|
||||||
]
|
]
|
||||||
# delve is unsupported on aarch64-linux and golangci-lint is broken on x86_64-darwin
|
# delve is unsupported on aarch64-linux and golangci-lint is broken on darwin
|
||||||
# (see https://github.com/NixOS/nixpkgs/issues/168984).
|
# (see https://github.com/NixOS/nixpkgs/issues/168984).
|
||||||
++ lib.optionals (system != "aarch64-linux" && system != "x86_64-darwin") [ vim-go ];
|
++ lib.optionals (system != "aarch64-linux" && !pkgs.stdenv.isDarwin ) [ vim-go ];
|
||||||
programs.neovim.extraConfig = ''
|
programs.neovim.extraConfig = ''
|
||||||
lua <<EOF
|
lua <<EOF
|
||||||
${builtins.readFile ./dev.lua}
|
${builtins.readFile ./dev.lua}
|
||||||
|
${builtins.readFile ./lspconfig-volar.lua}
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
}
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
local lspconfig = require'lspconfig'
|
||||||
|
local lspconfig_configs = require'lspconfig.configs'
|
||||||
|
local lspconfig_util = require 'lspconfig.util'
|
||||||
|
|
||||||
|
local function on_new_config(new_config, new_root_dir)
|
||||||
|
local function get_typescript_server_path(root_dir)
|
||||||
|
local project_root = lspconfig_util.find_node_modules_ancestor(root_dir)
|
||||||
|
return project_root and (lspconfig_util.path.join(project_root, 'node_modules', 'typescript', 'lib', 'tsserverlibrary.js'))
|
||||||
|
or ''
|
||||||
|
end
|
||||||
|
|
||||||
|
if
|
||||||
|
new_config.init_options
|
||||||
|
and new_config.init_options.typescript
|
||||||
|
and new_config.init_options.typescript.serverPath == ''
|
||||||
|
then
|
||||||
|
new_config.init_options.typescript.serverPath = get_typescript_server_path(new_root_dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local volar_cmd = {'vue-language-server', '--stdio'}
|
||||||
|
local volar_root_dir = lspconfig_util.root_pattern 'package.json'
|
||||||
|
|
||||||
|
lspconfig_configs.volar_api = {
|
||||||
|
default_config = {
|
||||||
|
cmd = volar_cmd,
|
||||||
|
root_dir = volar_root_dir,
|
||||||
|
on_new_config = on_new_config,
|
||||||
|
filetypes = { 'vue'},
|
||||||
|
-- If you want to use Volar's Take Over Mode (if you know, you know)
|
||||||
|
--filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' },
|
||||||
|
init_options = {
|
||||||
|
typescript = {
|
||||||
|
serverPath = ''
|
||||||
|
},
|
||||||
|
languageFeatures = {
|
||||||
|
implementation = true, -- new in @volar/vue-language-server v0.33
|
||||||
|
references = true,
|
||||||
|
definition = true,
|
||||||
|
typeDefinition = true,
|
||||||
|
callHierarchy = true,
|
||||||
|
hover = true,
|
||||||
|
rename = true,
|
||||||
|
renameFileRefactoring = true,
|
||||||
|
signatureHelp = true,
|
||||||
|
codeAction = true,
|
||||||
|
workspaceSymbol = true,
|
||||||
|
completion = {
|
||||||
|
defaultTagNameCase = 'both',
|
||||||
|
defaultAttrNameCase = 'kebabCase',
|
||||||
|
getDocumentNameCasesRequest = false,
|
||||||
|
getDocumentSelectionRequest = false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lspconfig.volar_api.setup{}
|
||||||
|
|
||||||
|
lspconfig_configs.volar_doc = {
|
||||||
|
default_config = {
|
||||||
|
cmd = volar_cmd,
|
||||||
|
root_dir = volar_root_dir,
|
||||||
|
on_new_config = on_new_config,
|
||||||
|
|
||||||
|
filetypes = { 'vue'},
|
||||||
|
-- If you want to use Volar's Take Over Mode (if you know, you know):
|
||||||
|
--filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' },
|
||||||
|
init_options = {
|
||||||
|
typescript = {
|
||||||
|
serverPath = ''
|
||||||
|
},
|
||||||
|
languageFeatures = {
|
||||||
|
implementation = true, -- new in @volar/vue-language-server v0.33
|
||||||
|
documentHighlight = true,
|
||||||
|
documentLink = true,
|
||||||
|
codeLens = { showReferencesNotification = true},
|
||||||
|
-- not supported - https://github.com/neovim/neovim/pull/15723
|
||||||
|
semanticTokens = false,
|
||||||
|
diagnostics = true,
|
||||||
|
schemaRequestService = true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lspconfig.volar_doc.setup{}
|
||||||
|
|
||||||
|
lspconfig_configs.volar_html = {
|
||||||
|
default_config = {
|
||||||
|
cmd = volar_cmd,
|
||||||
|
root_dir = volar_root_dir,
|
||||||
|
on_new_config = on_new_config,
|
||||||
|
|
||||||
|
filetypes = { 'vue'},
|
||||||
|
-- If you want to use Volar's Take Over Mode (if you know, you know), intentionally no 'json':
|
||||||
|
--filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
|
||||||
|
init_options = {
|
||||||
|
typescript = {
|
||||||
|
serverPath = ''
|
||||||
|
},
|
||||||
|
documentFeatures = {
|
||||||
|
selectionRange = true,
|
||||||
|
foldingRange = true,
|
||||||
|
linkedEditingRange = true,
|
||||||
|
documentSymbol = true,
|
||||||
|
-- not supported - https://github.com/neovim/neovim/pull/13654
|
||||||
|
documentColor = false,
|
||||||
|
documentFormatting = {
|
||||||
|
defaultPrintWidth = 100,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lspconfig.volar_html.setup{}
|
Loading…
Reference in New Issue