Tutorial: nvim-lspconfig - how to set up multiple language servers #606
Replies: 10 comments 21 replies
-
Thanks for your share! The feature icon does not consider how to set it, it just shows whether the feature is available, so I will add it. :) |
Beta Was this translation helpful? Give feedback.
-
@sethidden Hey, thanks for that. I had to update the imports of the configs and util to the following to make it work
Apparently they changed how those were referenced and it was supposed to be like that |
Beta Was this translation helpful? Give feedback.
-
Heads up for the new package and binary name change #876 - make sure to remove @volar/server and use @volar/vue-language-server instead. Also stop using the binary The changes have been reflected in the original post |
Beta Was this translation helpful? Give feedback.
-
How to install the
this is my npm global package. lua ➤ npm list -g git:master*
/usr/local/lib
├── @vue/cli@5.0.7
├── eslint@8.19.0
├── neovim@4.10.1
├── npm@8.12.1
├── pyright@1.1.233
├── typescript@4.7.4
├── vue-language-server@0.0.67
└── wscat@5.1.0 my NeoVim version: lua ➤ nvim --version git:master*
NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by runner@Mac-1656256708179.local
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"
Run :checkhealth for more info |
Beta Was this translation helpful? Give feedback.
-
oh, this config code can vite-typescript project only. 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)
-- You should run [ npm install typescript ] in your vue project 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 |
Beta Was this translation helpful? Give feedback.
-
Is this configuration still relevant with the removal of |
Beta Was this translation helpful? Give feedback.
-
I used this config: Lua Configlocal 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')) or ''
end
if
new_config.init_options
and new_config.init_options.typescript
and new_config.init_options.typescript.tsdk == ''
then
new_config.init_options.typescript.tsdk = 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 = {
tsdk = '/Users/alex/.nvm/versions/node/v16.13.2/lib/node_modules/typescript/lib'
},
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 = {
tsdk = '/Users/alex/.nvm/versions/node/v16.13.2/lib/node_modules/typescript/lib'
},
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 = {
tsdk = '/Users/alex/.nvm/versions/node/v16.13.2/lib/node_modules/typescript/lib'
},
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{} But I got serious memory issues in Mac M1 chip when opening a Vue file, is there something I'm doing wrong? Also, I tried these two suggested configs but I do not get autocompletion and linting does not seem to work. Any other suggestion? Here are some logs: Click me[START][2022-11-03 18:04:19] LSP logging initiated
[WARN][2022-11-03 18:04:19] ...lsp/handlers.lua:113 "The language server volar triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[ERROR][2022-11-03 18:04:23] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Solargraph is listening on stdio PID=66965\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "\n<--- Last few GCs --->\n\n[66929:0x138008000] 5120 ms: Mark-sweep (reduce) 4088.9 (4106.6) -> 4088.9 (4096.9) MB, 25.1 / 0.0 ms (+ 34.0 ms in 29 steps since start of marking, biggest step 10.2 ms, walltime since start of marking 397 ms) (average mu = 0.933, current mu = 0.924[66929:0x138008000] 5179 ms: Mark-sweep (reduce) 4100.1 (4108.1) -> 4099.8 (4108.1) MB, 50.3 / 0.0 ms (average mu = 0.875, current mu = 0.145) allocation failure scavenge might not succeed\n\n\n<--- JS stacktrace --->\n\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 1: 0x102a3f508 node::Abort() [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 2: 0x102a3f690 node::errors::TryCatchScope::~TryCatchScope() [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 3: 0x102b8d9b4 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 4: 0x102b8d948 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 5: 0x102d10e08 v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 6: 0x102d0f928 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 7: 0x102d1ac04 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 8: 0x102d1ac98 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" " 9: 0x102ce7b98 v8::internal::FactoryBase<v8::internal::Factory>::NewRawTwoByteString(int, v8::internal::AllocationType) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "10: 0x102cef768 v8::internal::Factory::NewStringFromUtf8(v8::base::Vector<char const> const&, v8::internal::AllocationType) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "11: 0x102bb0094 v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "12: 0x102aed6e4 node::StringBytes::Encode(v8::Isolate*, char const*, unsigned long, node::encoding, v8::Local<v8::Value>*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "13: 0x102a2354c void node::Buffer::(anonymous namespace)::StringSlice<(node::encoding)1>(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "14: 0x102bfa77c v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "15: 0x102bfa274 v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "16: 0x102bf9b00 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "17: 0x10333762c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "18: 0x107516514 \n19: 0x10751ed14 \n20: 0x1075cd724 \n21: 0x1075b4c2c \n22: 0x1075b4ab0 \n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "23: 0x1032c2ba8 Builtins_CallProxy [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n24: 0x1075b6590 \n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "25: 0x1075b1c04 \n26: 0x1075c95e8 \n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "27: 0x1032cb178 Builtins_InterpreterEntryTrampoline [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "28: 0x103381768 Builtins_ProxyGetProperty [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "29: 0x1033bd21c Builtins_LdaNamedPropertyHandler [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "30: 0x1032cb178 Builtins_InterpreterEntryTrampoline [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "31: 0x1032cb178 Builtins_InterpreterEntryTrampoline [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "32: 0x1032cb178 Builtins_InterpreterEntryTrampoline [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "33: 0x1032cb178 Builtins_InterpreterEntryTrampoline [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "34: 0x1032fc94c Builtins_GeneratorPrototypeNext [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "35: 0x1032cb178 Builtins_InterpreterEntryTrampoline [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "36: 0x10337f618 Builtins_PromiseFulfillReactionJob [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "37: 0x1032ecb54 Builtins_RunMicrotasks [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "38: 0x1032c8e44 Builtins_JSRunMicrotasksEntry [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "39: 0x102c9d650 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "40: 0x102c9da84 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "41: 0x102c9db70 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle<v8::internal::Object>*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "42: 0x102cc079c v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "43: 0x102cc1030 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "44: 0x10298ed8c node::InternalCallbackScope::Close() [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "45: 0x10298e7c4 node::InternalCallbackScope::~InternalCallbackScope() [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "46: 0x1029ead28 node::Environment::RunTimers(uv_timer_s*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "47: 0x1032aa0c4 uv__run_timers [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "48: 0x1032ad0c8 uv_run [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "49: 0x10298fe00 node::SpinEventLoop(node::Environment*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "50: 0x102a786d4 node::NodeMainInstance::Run(int*, node::Environment*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "51: 0x102a783a0 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "52: 0x102a11388 node::Start(int, char**) [/Users/alex/.nvm/versions/node/v16.13.2/bin/node]\n"
[ERROR][2022-11-03 18:04:24] .../vim/lsp/rpc.lua:733 "rpc" "vue-language-server" "stderr" "53: 0x10741108c \n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Warning: obsolete parameter `IgnoredPatterns` (for `Layout/LineLength`) found in .rubocop.yml\n`IgnoredPatterns` has been renamed to `AllowedPatterns`.\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.\n\nPlease also note that you can opt-in to new cops by default by adding this to your config:\n AllCops:\n NewCops: enable\nGemspec/DeprecatedAttributeAssignment: # new in 1.30\n Enabled: true\nGemspec/RequireMFA: # new in 1.23\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Layout/LineContinuationLeadingSpace: # new in 1.31\n Enabled: true\nLayout/LineContinuationSpacing: # new in 1.31\n Enabled: true\nLayout/LineEndStringConcatenationIndentation: # new in 1.18\n Enabled: true\nLayout/SpaceBeforeBrackets: # new in 1.7\n Enabled: true\nLint/AmbiguousAssignment: # new in 1.7\n Enabled: true\nLint/AmbiguousOperatorPrecedence: # new in 1.21\n Enabled: true\nLint/AmbiguousRange: # new in 1.19\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/ConstantOverwrittenInRescue: # new in 1.31\n Enabled: true\nLint/DeprecatedConstants: # new in 1.8\n Enabled: true\nLint/DuplicateBranch: # new in 1.3\n Enabled: true\nLint/DuplicateRegexpCharacterClassElement: # new in 1.1\n Enabled: true\nLint/EmptyBlock: # new in 1.1\n Enabled: true\nLint/EmptyClass: # new in 1.3\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/EmptyInPattern: # new in 1.16\n Enabled: true\nLint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21\n Enabled: true\nLint/LambdaWithoutLiteralBlock: # new in 1.8\n Enabled: true\nLint/NoReturnInBeginEndBlocks: # new in 1.2\n Enabled: true\nLint/NonAtomicFileOperation: # new in 1.31\n Enabled: true\nLint/NumberedParameterAssignment: # new in 1.9\n Enabled: true\nLint/OrAssignmentToConstant: # new in 1.9\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/RedundantDirGlobSort: # new in 1.8\n Enabled: true\nLint/RefinementImportMethods: # new in 1.27\n Enabled: true\nLint/RequireRangeParentheses: # new in 1.32\n Enabled: true\nLint/RequireRelativeSelfPath: # new in 1.22\n Enabled: true\nLint/SymbolConversion: # new in 1.9\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nLint/ToEnumArguments: # new in 1.1\n Enabled: true\nLint/TripleQuotes: # new in 1.9\n Enabled: true\nLint/UnexpectedBlockArity: # new in 1.5\n Enabled: true\nLint/UnmodifiedReduceAccumulator: # new in 1.1\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nLint/UselessRuby2Keywords: # new in 1.23\n Enabled: true\nNaming/BlockForwarding: # new in 1.24\n Enabled: true\nSecurity/CompoundHash: # new in 1.28\n Enabled: true\nSecurity/IoMethods: # new in 1.22\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nStyle/ArgumentsForwarding: # new in 1.1\n Enabled: true\nStyle/CollectionCompact: # new in 1.2\n Enabled: true\nStyle/DocumentDynamicEvalDefinition: # new in 1.1\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/EmptyHeredoc: # new in 1.32\n Enabled: true\nStyle/EndlessMethod: # new in 1.8\n Enabled: true\nStyle/EnvHome: # new in 1.29\n Enabled: true\nStyle/FetchEnvVar: # new in 1.28\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/FileRead: # new in 1.24\n Enabled: true\nStyle/FileWrite: # new in 1.24\n Enabled: true\nStyle/HashConversion: # new in 1.10\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/HashExcept: # new in 1.7\n Enabled: true\nStyle/IfWithBooleanLiteralBranches: # new in 1.9\n Enabled: true\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/InPatternThen: # new in 1.16\n Enabled: true\nStyle/MapCompactWithConditionalBlock: # new in 1.30\n Enabled: true\nStyle/MapToHash: # new in 1.24\n Enabled: true\nStyle/MultilineInPatternThen: # new in 1.16\n Enabled: true\nStyle/NegatedIfElseCondition: # new in 1.2\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nStyle/NestedFileDirname: # new in 1.26\n Enabled: true\nStyle/NilLambda: # new in 1.3\n Enabled: true\nStyle/NumberedParameters: # new in 1.22\n Enabled: true\nStyle/NumberedParametersLimit: # new in 1.22\n Enabled: true\nStyle/ObjectThen: # new in 1.28\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nStyle/OpenStructUse: # new in 1.23\n Enabled: true\nStyle/QuotedSymbols: # new in 1.16\n Enabled: true\nStyle/RedundantArgument: # new in 1.4\n Enabled: true\nStyle/RedundantInitialize: # new in 1.27\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nStyle/RedundantSelfAssignmentBranch: # new in 1.19\n Enabled: true\nStyle/SelectByRegexp: # new in 1.22\n Enabled: true\nStyle/StringChars: # new in 1.12\n Enabled: true\nStyle/SwapValues: # new in 1.1\n"
[ERROR][2022-11-03 18:04:27] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nFor more information: https://docs.rubocop.org/rubocop/versioning.html\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Warning: obsolete parameter `IgnoredPatterns` (for `Layout/LineLength`) found in .rubocop.yml\n`IgnoredPatterns` has been renamed to `AllowedPatterns`.\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.\n\nPlease also note that you can opt-in to new cops by default by adding this to your config:\n AllCops:\n NewCops: enable\nGemspec/DeprecatedAttributeAssignment: # new in 1.30\n Enabled: true\nGemspec/RequireMFA: # new in 1.23\n Enabled: true\nLayout/LineContinuationLeadingSpace: # new in 1.31\n Enabled: true\nLayout/LineContinuationSpacing: # new in 1.31\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Layout/LineEndStringConcatenationIndentation: # new in 1.18\n Enabled: true\nLayout/SpaceBeforeBrackets: # new in 1.7\n Enabled: true\nLint/AmbiguousAssignment: # new in 1.7\n Enabled: true\nLint/AmbiguousOperatorPrecedence: # new in 1.21\n Enabled: true\nLint/AmbiguousRange: # new in 1.19\n Enabled: true\nLint/ConstantOverwrittenInRescue: # new in 1.31\n Enabled: true\nLint/DeprecatedConstants: # new in 1.8\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/DuplicateBranch: # new in 1.3\n Enabled: true\nLint/DuplicateRegexpCharacterClassElement: # new in 1.1\n Enabled: true\nLint/EmptyBlock: # new in 1.1\n Enabled: true\nLint/EmptyClass: # new in 1.3\n Enabled: true\nLint/EmptyInPattern: # new in 1.16\n Enabled: true\nLint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/LambdaWithoutLiteralBlock: # new in 1.8\n Enabled: true\nLint/NoReturnInBeginEndBlocks: # new in 1.2\n Enabled: true\nLint/NonAtomicFileOperation: # new in 1.31\n Enabled: true\nLint/NumberedParameterAssignment: # new in 1.9\n Enabled: true\nLint/OrAssignmentToConstant: # new in 1.9\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/RedundantDirGlobSort: # new in 1.8\n Enabled: true\nLint/RefinementImportMethods: # new in 1.27\n Enabled: true\nLint/RequireRangeParentheses: # new in 1.32\n Enabled: true\nLint/RequireRelativeSelfPath: # new in 1.22\n Enabled: true\nLint/SymbolConversion: # new in 1.9\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Lint/ToEnumArguments: # new in 1.1\n Enabled: true\nLint/TripleQuotes: # new in 1.9\n Enabled: true\nLint/UnexpectedBlockArity: # new in 1.5\n Enabled: true\nLint/UnmodifiedReduceAccumulator: # new in 1.1\n Enabled: true\nLint/UselessRuby2Keywords: # new in 1.23\n Enabled: true\nNaming/BlockForwarding: # new in 1.24\n Enabled: true\nSecurity/CompoundHash: # new in 1.28\n Enabled: true\nSecurity/IoMethods: # new in 1.22\n Enabled: true\nStyle/ArgumentsForwarding: # new in 1.1\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/CollectionCompact: # new in 1.2\n Enabled: true\nStyle/DocumentDynamicEvalDefinition: # new in 1.1\n Enabled: true\nStyle/EmptyHeredoc: # new in 1.32\n Enabled: true\nStyle/EndlessMethod: # new in 1.8\n Enabled: true\nStyle/EnvHome: # new in 1.29\n Enabled: true\nStyle/FetchEnvVar: # new in 1.28\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/FileRead: # new in 1.24\n Enabled: true\nStyle/FileWrite: # new in 1.24\n Enabled: true\nStyle/HashConversion: # new in 1.10\n Enabled: true\nStyle/HashExcept: # new in 1.7\n Enabled: true\nStyle/IfWithBooleanLiteralBranches: # new in 1.9\n Enabled: true\nStyle/InPatternThen: # new in 1.16\n Enabled: true\nStyle/MapCompactWithConditionalBlock: # new in 1.30\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" " Enabled: true\nStyle/MapToHash: # new in 1.24\n Enabled: true\nStyle/MultilineInPatternThen: # new in 1.16\n Enabled: true\nStyle/NegatedIfElseCondition: # new in 1.2\n Enabled: true\nStyle/NestedFileDirname: # new in 1.26\n Enabled: true\nStyle/NilLambda: # new in 1.3\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/NumberedParameters: # new in 1.22\n Enabled: true\nStyle/NumberedParametersLimit: # new in 1.22\n Enabled: true\nStyle/ObjectThen: # new in 1.28\n Enabled: true\nStyle/OpenStructUse: # new in 1.23\n Enabled: true\nStyle/QuotedSymbols: # new in 1.16\n Enabled: true\nStyle/RedundantArgument: # new in 1.4\n Enabled: true\nStyle/RedundantInitialize: # new in 1.27\n Enabled: true\nStyle/RedundantSelfAssignmentBranch: # new in 1.19\n Enabled: true\nStyle/SelectByRegexp: # new in 1.22\n Enabled: true\n"
[ERROR][2022-11-03 18:04:43] .../vim/lsp/rpc.lua:733 "rpc" "solargraph" "stderr" "Style/StringChars: # new in 1.12\n Enabled: true\nStyle/SwapValues: # new in 1.1\n Enabled: true\nFor more information: https://docs.rubocop.org/rubocop/versioning.html\n" |
Beta Was this translation helpful? Give feedback.
-
Your config is not working well and took 2GB of memorey. That's bad. So, I figure out myself as follow. Ppl who are stuck with volar setup in nvim just copy and paste the following code snippets to your lspconfig. lspconfig.volar.setup {} will work well. You can attach volar's config what u want to. These guy's config not working well. You can use
|
Beta Was this translation helpful? Give feedback.
-
and
both ways are not working. I cannot see type definition with lsp hover and also cannot go to definitions. Also no suggestion in insdie Here's my lspconfig.-- lspconfig.lua
-- https://github.com/wai-lin/nvim/blob/main/lua/plugins/lspconfig.lua
local servers = {
html = {},
cssls = {},
tsserver = {},
eslint = {},
tailwindcss = {},
volar = {
filetypes = { "vue" },
settings = {
volar = {
codeLens = {
references = true,
pugTools = true,
scriptSetupTools = true,
},
},
},
},
svelte = {},
jsonls = {},
gopls = {},
templ = {},
ocamllsp = {},
elixirls = {},
stylua = {},
lua_ls = {
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
workspace = {
checkThirdParty = false,
library = {
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
[vim.fn.stdpath "config" .. "/lua"] = true,
},
-- library = {
-- '${3rd}/luv/library',
-- unpack(vim.api.nvim_get_runtime_file('', true)),
-- },
},
completion = {
callSnippet = 'Replace',
},
},
},
},
}
-- Attach LSP related
-- keymaps and autocommands on buffers
local on_attach = function()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lsp-attach", { clear = true }),
callback = function(event)
local map = function(keys, func, desc)
vim.keymap.set("n", keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
map('K', vim.lsp.buf.hover, 'Hover Documentation')
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed
--
-- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
callback = vim.lsp.buf.clear_references,
})
end
end
})
end
return {
"williamboman/mason.nvim",
lazy = false,
dependencies = {
"neovim/nvim-lspconfig",
"williamboman/mason-lspconfig.nvim",
{ "j-hui/fidget.nvim", opts = {} },
},
opts = {},
config = function()
on_attach()
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
require("mason").setup()
local ensured_installed = vim.tbl_keys(servers or {})
require("mason-lspconfig").setup({
ensured_installed = ensured_installed,
})
for server_name in pairs(servers) do
require("lspconfig")[server_name].setup(servers[server_name] or {})
end
-- NOTE : Separately setup Vue3 for multi language servers setup
-- https://github.com/vuejs/language-tools/discussions/606
-- require("plugins.lsp_configs.volar")
end,
} Here's my volar multi language server.-- volar.lua
-- https://github.com/wai-lin/nvim/blob/main/lua/plugins/lsp_configs/volar.lua
local lspconfig = require("lspconfig")
local lspconfig_configs = require("lspconfig.configs")
local lspconfig_util = require("lspconfig.util")
local global_ts_server_path =
"/Users/wai-lin/Library/pnpm/nodejs/20.11.1/lib/node_modules/typescript/lib/tsserverlibrary.js"
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.tsdk == ""
then
new_config.init_options.typescript.tsdk = get_typescript_server_path(new_root_dir) or global_ts_server_path
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" },
init_options = {
typescript = { tsdk = "" },
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" },
init_options = {
typescript = { tsdk = "" },
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" },
init_options = {
typescript = { tsdk = "" },
documentFeatures = {
selectionRange = true,
foldingRange = true,
linkedEditingRange = true,
documentSymbol = true,
-- not supported - https://github.com/neovim/neovim/pull/13654
documentColor = false,
documentFormatting = {
defaultPrintWidth = 100,
},
}
},
}
}
l |
Beta Was this translation helpful? Give feedback.
-
On my current setup it seems like typescript LSP can't distinguish between That is my LSP setup
|
Beta Was this translation helpful? Give feedback.
-
Note: Doing this is optional. Using just the standard nvim-lspconfig
require'lspconfig'.volar.setup{}
instead of the code below is completely fine. What "multiple language servers" does in the context of Volar is explained here: #393 (reply in thread)Anyways, this evening I had some time to set up multiple language servers for nvim-lspconfig. I pretty much split what's already in nvim-lspconfig into three separate servers (volar_api, volar_doc and volar_html), the same way it's already done in coc-volar.
It's worth thinking about adding it to nvim-lspconfig itself later, but having three separate lsp configs for one LS (Volar) that need to be launched together would introduce some disorder to nvim-lspconfig. Maybe it'd be worth publishing a separate plugin for Neovim?
I don't think this makes nvim deserve the lightning icon in the Community IDE list in README.md because of how user unfriendly it is :P
Below is the code you'd put in your
init.lua
(this is a tutorial for neovim, not vim):Beta Was this translation helpful? Give feedback.
All reactions