Giter Site home page Giter Site logo

nvim-lspconfig's Introduction

nvim-lspconfig

Configs for the Nvim LSP client (:help lsp).

  • Do not file Nvim LSP client issues here. The Nvim LSP client does not live here. This is only a collection of LSP configs.
  • If you found a bug in the Nvim LSP client, report it at the Nvim core repo.
  • These configs are best-effort and supported by the community. See contributions.

See also :help lspconfig.

Install

LuaRocks

  • Requires neovim version 0.8 above. Update Nvim and nvim-lspconfig before reporting an issue.

  • Install nvim-lspconfig using builtin packages:

    git clone https://github.com/neovim/nvim-lspconfig ~/.config/nvim/pack/nvim/start/nvim-lspconfig
    
  • Alternatively, nvim-lspconfig can be installed using a 3rd party plugin manager (consult the documentation for your plugin manager for details).

Quickstart

  1. Install a language server, e.g. pyright
    npm i -g pyright
  2. Add the language server setup to your init.lua.
    require'lspconfig'.pyright.setup{}
  3. Launch Nvim, the language server will attach and provide diagnostics.
    nvim main.py
    
  4. Run :checkhealth lsp to see the status or to troubleshoot.

See server_configurations.md (:help lspconfig-all from Nvim) for the full list of configs, including installation instructions and additional, optional, customization suggestions for each language server. For servers that are not on your system path (e.g., jdtls, elixirls), you must manually add cmd to the setup parameter. Most language servers can be installed in less than a minute.

Configuration

Nvim sets some default options whenever a buffer attaches to an LSP client. See :h lsp-config for more details. In particular, the following options are set:

Nvim also maps K to vim.lsp.buf.hover() in Normal mode.

Nvim 0.10 and newer creates the following default maps unconditionally:

  • crr in Normal mode maps to vim.lsp.buf.code_action()
  • <C-R>r and <C-R><C-R> in Visual mode map to vim.lsp.buf.code_action()
  • crn in Normal mode maps to vim.lsp.buf.rename()
  • gr in Normal mode maps to vim.lsp.buf.references()
  • <C-S> in Insert mode maps to vim.lsp.buf.signature_help()
  • [d and ]d map to vim.diagnostic.goto_prev() and vim.diagnostic.goto_next() (respectively)
  • <C-W>d maps to vim.diagnostic.open_float()

Further customization can be achieved using the LspAttach autocommand event. The LspDetach autocommand event can be used to "cleanup" mappings if a buffer becomes detached from an LSP server. See :h LspAttach and :h LspDetach for details and examples. See :h lsp-buf for details on other LSP functions.

Additional configuration options can be provided for each LSP server by passing arguments to the setup function. See :h lspconfig-setup for details. Example:

local lspconfig = require('lspconfig')
lspconfig.rust_analyzer.setup {
  -- Server-specific settings. See `:help lspconfig-setup`
  settings = {
    ['rust-analyzer'] = {},
  },
}

Troubleshooting

If you have an issue, the first step is to reproduce with a minimal configuration.

The most common reasons a language server does not start or attach are:

  1. The language server is not installed. nvim-lspconfig does not install language servers for you. You should be able to run the cmd defined in each server's Lua module from the command line and see that the language server starts. If the cmd is an executable name instead of an absolute path to the executable, ensure it is on your path.
  2. Missing filetype plugins. Certain languages are not detecting by vim/neovim because they have not yet been added to the filetype detection system. Ensure :set ft? shows the filetype and not an empty value.
  3. Not triggering root detection. Some language servers will only start if it is opened in a directory, or child directory, containing a file which signals the root of the project. Most of the time, this is a .git folder, but each server defines the root config in the lua file. See server_configurations.md or the source for the list of root directories.
  4. You must pass on_attach and capabilities for each setup {} if you want these to take effect.
  5. Do not call setup {} twice for the same server. The second call to setup {} will overwrite the first.

Before reporting a bug, check your logs and the output of :LspInfo. Add the following to your init.vim to enable logging:

vim.lsp.set_log_level("debug")

Attempt to run the language server, and open the log with:

:LspLog

Most of the time, the reason for failure is present in the logs.

Commands

  • :LspInfo shows the status of active and configured language servers.
  • :LspStart <config_name> Start the requested server name. Will only successfully start if the command detects a root directory matching the current config. Pass autostart = false to your .setup{} call for a language server if you would like to launch clients solely with this command. Defaults to all servers matching current buffer filetype.
  • :LspStop <client_id> Defaults to stopping all buffer clients.
  • :LspRestart <client_id> Defaults to restarting all buffer clients.

Wiki

See the wiki for additional topics, including:

Contributions

If you are missing a language server on the list in server_configurations.md, contributing a new configuration for it helps others, especially if the server requires special setup. Follow these steps:

  1. Read CONTRIBUTING.md.
  2. Create a new file at lua/lspconfig/server_configurations/SERVER_NAME.lua.
  3. Ask questions on GitHub Discussions or in the Neovim Matrix room.

Release process

To publish a release:

  • Create and push a new tag.
  • After pushing the tag, a GitHub action will automatically package the plugin and publish the release to LuaRocks.

License

Copyright Neovim contributors. All rights reserved.

nvim-lspconfig is licensed under the terms of the Apache 2.0 license.

See LICENSE.md

nvim-lspconfig's People

Contributors

chrisgrieser avatar ckipp01 avatar clason avatar decodetalkers avatar dependabot[bot] avatar dundargoc avatar emilioziniades avatar erw7 avatar figsoda avatar folke avatar genesistms avatar github-actions[bot] avatar glepnir avatar h-michael avatar hiphish avatar iron-e avatar julian avatar justinmk avatar kdheepak avatar kylo252 avatar lewis6991 avatar lithammer avatar mhartington avatar mjlbach avatar mrcjkb avatar shatur avatar sigmasd avatar teto avatar williamboman avatar wlacruzpy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-lspconfig's Issues

[gopls] delay diagnostics or not run them in insert mode

Is there any way to force a particular lsp server to delay its diagnostics, or not run them during insert mode?

gopls is tends to be quite chatty when i'm writing and i see a lot of temporary diagnostics virtual texts. Worse yet, at some point in time, the following messages (in a different buffer) start being printed out, causing pauses in the ui:

LSP[gopls] 2020/02/17 09:01:01 failed to fix AST: unable to parse defer or go from *ast.BadStmt: no defer or go statement found

[rust_analyzer] initalizationOptions causing ra_lsp_server an error

Because of how vim json_encode transform vim data into JSON data, the lua value {} which is the default value for init_options is being encoded into an empty JSON array.
But ra_lsp_server expect to receive a JSON map for decoding the init options and emit an error: failed to deserialize config: invalid length 0, expected struct ServerConfig with 12 elements when receiving an empty initializationOptions by vim.lsp.
Hopefully rust-analyzer handle this error by just logging it and sticking with default values, but still the error message appears, which can be actually confusing.

Crash when using rust-analyzer.

Environment Information

  • OS: MAC
  • NVIM: 0.5.0 5d5b068
  • rust-analyzer: 5bf669860984a2c058b3bdc3e43b4993a0f25b31
  • nvim-lsp: 42385dbf6a5eac40da213322fdd3037588eede56

Provide a minimal settings

lsp.lua

vim.cmd('packadd nvim-lsp')
require'nvim_lsp'.rls.setup{}
require'nvim_lsp'.rust_analyzer.setup{}

Error

Vim(lua):E5108: Error executing lua [string ":lua"]:1: attempt to index a boolean value
LSP[rust_analyzer] Failed to deserialize config: invalid length 0, expected struct ServerConfig with 12 elements; []

LspInstall tsserver fails

I am having issues installing the LSP for tsserver using the :LspInstall tsserver command.

npm WARN saveError ENOENT: no such file or directory, open '/../.cache/nvim/nvim_lsp/tsserver/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/../.cache/nvim/nvim_lsp/tsserver/package.json'
npm WARN tsserver No repository field.
npm WARN tsserver No README data
npm WARN tsserver No license field.

The folder exists but only has the lock file.

nvim/nvim_lsp/tsserver 
> ls                                                     
node_modules      package-lock.json
  • NVIM v0.5.0-013436c99

I am not sure how to check the version of nvim-lsp, but I use plug and it says that it is up to date. LMK if I can provide additional debug info!

rename to nvim-lspconfig

Probably should have anticipated this, but people are confused about nvim-lsp (this repo, not Nvim-builtin) vs vim.lsp (Nvim builtin). Although the nvim-lsp README.md makes it clear, it still confuses people in discussions (example), and people who are just getting started.

So we should

  • rename this repo to nvim-lspconf nvim-lsp.configs
  • it also makes sense to rename the Lua module: it is confusing that require'nvim_lsp' is distinct from vim.lsp, since their names are semantically equivalent

I will do so in the next ~week if there are no objections.

cc @norcalli

General configuration example

I have gotten the clangd backend working.

However, I have not idea how to make it work like in the example video you posted on reddit: https://v.redd.it/lfi72durjay31

Perhaps this is not the place for it, but I would think that it handy to have a example config that shows how to turn on all the bells and whistles of the LSP client.

For example the automatic popups on hover and so on.

EDIT: I do have the commands from :h lsp.txt. But I just want to make sure that there is nothing else that I'm missing.

ccls: remove inaccurate vscode client initialization options from docgen

I'm having trouble figuring out how to specify initialization options for ccls (the only LSP server I've tested so far) using the settings key. Say I want ccls.cache.directory to be /tmp/ccls-cache, using a command switch I can achieve it like the following

local nvim_lsp = require 'nvim_lsp'
nvim_lsp.ccls.setup{
    cmd = {
        'ccls',
        '--init={"cache": {"directory": "/tmp/ccls-cache"}}'
    };
}

That works. I'd like to be able to do the same using the settings key, but I can't. For instance, neither

local nvim_lsp = require 'nvim_lsp'
nvim_lsp.ccls.setup{
    cmd = {
        'ccls'
    };
    settings = {
        ccls = {
            cache = {
                directory = "/tmp/ccls-cache";
            };
        };
    };
}

nor

local nvim_lsp = require 'nvim_lsp'
nvim_lsp.ccls.setup{
    cmd = {
        'ccls'
    };
    settings = {
        cache = {
            directory = "/tmp/ccls-cache";
        };
    };
}

work. Looking into ccls's log, the cache option is not even being sent to the server when initializing it.

Am I doing something wrong?

Environment

  • NVIM v0.5.0-233-g76d1e9360

setup() on_attach signature

doc for setup() mentions:

{on_attach}
function(client) executed with the current buffer as the one the {client} is being attached-to. This is different from |vim.lsp.start_client()|'s on_attach parameter, which passes the {bufnr} as the second parameter instead. Useful for doing buffer-local setup.

The fact that the doc feels the need to mention "This is different from ..." is a strong hint that it shouldn't be different. One or the other should be changed.

Can not make auto-completion for python work

I am using the latest version of neovim which supports lsp.

I have installed nvim-lsp using vim-plug. I have also installed the python-language server and the jedi package.

I followed the config here and add the following to init.vim:

call plug#begin('~/.local/share/nvim/plugged')
Plug 'neovim/nvim-lsp'
call plug#end()

let settings = {
          \   "pyls" : {
          \     "enable" : v:true,
          \     "trace" : { "server" : "verbose", },
          \     "commandPath" : "",
          \     "configurationSources" : [ "pycodestyle" ],
          \     "plugins" : {
          \       "jedi_completion" : { "enabled" : v:true, },
          \       "jedi_hover" : { "enabled" : v:true, },
          \       "jedi_references" : { "enabled" : v:true, },
          \       "jedi_signature_help" : { "enabled" : v:true, },
          \       "jedi_symbols" : {
          \         "enabled" : v:true,
          \         "all_scopes" : v:true,
          \       },
          \       "mccabe" : {
          \         "enabled" : v:true,
          \         "threshold" : 15,
          \       },
          \       "preload" : { "enabled" : v:true, },
          \       "pycodestyle" : { "enabled" : v:true, },
          \       "pydocstyle" : {
          \         "enabled" : v:false,
          \         "match" : "(?!test_).*\\.py",
          \         "matchDir" : "[^\\.].*",
          \       },
          \       "pyflakes" : { "enabled" : v:true, },
          \       "rope_completion" : { "enabled" : v:true, },
          \       "yapf" : { "enabled" : v:true, },
          \     }}}
    call nvim_lsp#setup("pyls", settings)

Then I start neovim with the following command:

nvim -u init.vim test.py

It seems that only linting works (see figure below). But auto-completion menu does not show up when I start typing something. Do I need extra settings to make auto-completion work? Like what is provided by deoplete or youcompleteme.

image

Is it possible to use it in command editing mode?

Is it possible to use it in command editing mode q:, q/, q??
The gif on the main page shows how you substitute in command-editing mode. But it doesn't seem to work on my vim instance.

mkdir -p /tmp/issue && cd /tmp/issue/
git clone https://github.com/osyo-manga/vim-over

minimal.init:

set runtimepath^=/tmp/issue/vim-over/
filetype plugin on
set hlsearch
set incsearch

nvim -u minimal.init somefile.txt

Error executing vim.schedule lua callback: Vim(for):E714: List required

I'm running into the following error during completion using the tsserver configuration. Other forms of completion (gopls, rust-lsp, etc) all work

Error executing vim.schedule lua callback: Vim(for):E714: List required 

This was originally reported to me on my loose wrapper for nvim-lsp for asyncomplete on this issue: DonnieWest/asyncomplete_neovim_lsp#1

I've since been able to replicate it on a small Javascript project, using the tsserver configuration and only using an omnifunc, so I was able to rule out my project.

I'm totally open to there being something wrong with how I'm configured. If I need more info, I'm happy to supply :)

E5105: Error when calling lua chunk

I just installed nvim-lsp using vim-plug and I get this error:

Wykryto błąd podczas przetwarzania /home/[user]/.local/share/nvim/plugged/nvim-lsp/plugin/nvim_
lsp.vim:
wiersz   11:
E5105: Error while calling lua chunk: ....local/share/nvim/plugged/nvim-lsp/lua/nvim_lsp/util.lua:29
3: attempt to index local 'fn' (a nil value)

System info:

OS: Archlinux, updated this morning

:version
NVIM v0.4.3
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -DNDEBUG -DMIN_LOG_LEVE
L=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversi
on -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=al
ways -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_
FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.3/src -I/usr/include -I/build/n
eovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Skompilowany przez builduser

Features: +acl +iconv +tui
See ":help feature-compile"

       vimrc systemu: "$VIM/sysinit.vim"
   odwet dla $VIM-a: "/usr/share/nvim"

Run :checkhealth for more info

vim-plug is up-to-date, according to PlugUpgrade
Lua version (lua -v): Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio

Add TCP support

Recently Godot 3.2 was released with LSP support. But LSP works only through Websocket. This PR switches Godot's LSP to TCP and now can be suported for the Vim plugins. I tested it with coc.nvim and everything works. Does nvim-lsp will support TCP?

auto-disable on fatal error (don't error on every buffer)

When nvim-lsp doesnt find the executable specified in the nvim-lsp config, it spits out a message.
Error executing lua ...9kqpskva35-neovim/share/nvim/runtime/lua/vim/lsp/rpc.lua:212: The given command "ghcide" is not executable.
If you change the current buffer, the autocmd triggers and the same error appears again and again.
coc.nvim only fails on the first bufffer.

This may be considered as a fault relying on the user environment so maybe we don't need to fix it but due to my setup (almost no program globally installed, all in virtual env), it happens quite often.

c++ completion for member functions not working

nvim ver: NVIM v0.5.0-161-g18096631b

  • how to reproduce:
    mkdir -p /tmp/issue && cd /tmp/issue/
    git clone https://github.com/neovim/nvim-lsp/

minimal.init:

set runtimepath^=/tmp/issue/nvim-lsp/
filetype plugin on
call nvim_lsp#setup("ccls", {})
setl omnifunc=lsp#omnifunc

cat > /tmp/issue/foo.cpp

#include <string>

int main()
{
    std::string s = "42";
}

CMakeLists.txt

project (a.out)

cmake_minimum_required(VERSION 3.5)

set (CMAKE_CXX_COMPILER "clang++")
set (CMAKE_BUILD_TYPE Debug)
set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)

set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wconversion -Wfatal-errors")

add_executable(a.out foo.cpp)

cmake . && make
nvim -u minimal.init foo.cpp

observe that omni-completion for s. returns
Omni completion (^O^N^P) Pattern not found

problems with clangd 7

(For reference, so others can find this)

clangd --version
clangd version 7.0.0-3~ubuntu0.18.04.1 (tags/RELEASE_700/final)

With the default clangd config from nvim-lsp:

~/.local/share/nvim/vim-lsp.log:

"rpc">  "clangd">       "stderr">       "clangd"
"rpc">  "clangd">       "stderr">       ": Unknown command line argument '"
"rpc">  "clangd">       "stderr">       "--background-index"
"rpc">  "clangd">       "stderr">       "'.  Try: '"
"rpc">  "clangd">       "stderr">       "clangd"
"rpc">  "clangd">       "stderr">       " -help'\n"
"rpc">  "clangd">       "stderr">       "clangd"
"rpc">  "clangd">       "stderr">       ": Did you mean '-"
"rpc">  "clangd">       "stderr">       "ppc-gen-isel"
"rpc">  "clangd">       "stderr">       "'?\n

That can be fixed by overriding cmd:

  local nvim_lsp = require 'nvim_lsp'              
  local util = require 'nvim_lsp/util'          
  nvim_lsp.clangd.setup {                                  
    cmd = {"clangd"},                                 
    root_dir = util.root_pattern('build/compile_commands.json', '.git'),
  }

Also note that Neovim puts build/compile_commands.json in "build" directory, so the root_dir is overridden there.

If I try to complete something in eval.c, this is the log result:

"I[16:01:24.764] Code complete: 0 results from Sema, 0 from Index, 0 matched, 0 returned.\n"
"I[16:01:24.764] --> reply(4)\n"         
"I[16:04:43.809] <-- textDocument/completion(5)\n"         
"I"         
"["         
"16:04:43.874"         
"] "         
"Code complete: Ignoring sema code complete callback with Recovery context."         
"\n"         
"I"         
"["         
"16:04:43.876"         
"] "         
"Code complete: "         
"0"         
" results from Sema, "         
"0"         
" from Index, "         
"0"         
" matched, "         
"0"         
" returned"         
"."         
"\n"         
"I"         
"["         
"16:04:43.879"         
"] "         
"--> reply("         
"5"                                                                                                                             
")"
"\n"

add diagnostics to quicklist

hi,

Some things I miss from coc.nvim:

  • having whole project diagnostics open in the quickfix
  • file specific diagnostics in locationlist

Then I suppose this is out of scope for the plugin, but coc.nvim has mappings to go to next diagnostic from current line. In case you have such a snippet, I am eager :p

Permission denied issues while using gopls

I'm having issues going to definition (vim.lsp.buf.definition()) while inside go mod installed packages.

LSP[gopls] 2019/12/03 20:35:25 no CheckPackageHandles: go [list -f {{context.GOARCH}} {{context.Compiler}} -- unsafe]: exit status 1: error writing go.mod: open /Users/florians
uess/go/pkg/mod/github.com/sirupsen/[email protected]/go.mod298498081.tmp: permission denied
Press ENTER or type command to continue
^IURI = file:///Users/floriansuess/go/pkg/mod/github.com/sirupsen/[email protected]/exported.go
Press ENTER or type command to continue

Note; these issues completely resolve themselves when nvim is fired in sudo.

LspInstall hates me (no pyls)

So, when you removed lsp#add_filetype_config() and made the general configuration impossible to use (and removed all examples from :he lsp.txt), I admit defeat and I pull in this plugin to the so-called “built-in” LSP client.

What should I do? Right, there is that awesome :LspInstall command:

:LspInstall
LspInstall      LspInstallInfo
:LspInstall    
tsserver  bashls    cssls     elmls
:LspInstall

OK, no luck with pyls (because of course bashls is a way more important than what just some mere Python programmers need). But, wait! There is lua/nvim_lsp/pyls.lua, so perhaps not all hope is lost. Adding

call nvim_lsp#setup("pyls", {})

to my $VIMRC and … it actually works! OK, I guess, thank you.

So, the only complaint in this ticket is that :LspInstall is useless for me (and a small sob that it is not possible to configure the client manually anymore; oh well).

Error in clangd on Windows.

Due to changes in 638dad1, the following error occurs when opening a C source file on Windows:

E5108: Error executing lua shared.lua:427: root_dir: expected directory, got C:\msys64\home\erw7\src\github.com\neovim\neovim\src\nvim\tui\tui.c

On Windows, the following result does not seem to be nil.

vim.loop.fs_stat('C:\\Windows\\System32\\notepad.exe\\.')

I think that if we add '.' to root_pattern on non-Windows, it always returns the directory where the file is located.

rename "skeleton" to "configs"

nvim_lsp/skeleton.lua is not really a skeleton, it's a configs class that provides

  1. actual functionality
  2. a bunch of configs

Each config is added to the configs object (FKA "skeleton") as a property. Those configs are not "templates", they are "configs". So we should clean up the wording in various places to say "config" instead of "skeleton"/"template".

General guideline: avoid extra jargon when possible.

Windows installation scripts

I want to add support for auto windows installation, but I'm not exactly sure what the existing procedure is for most of the servers.

The basic neovim installation procedure is that we provide a directory on stdpath("cache")/nvim_lsp/$server where you can download files and put binaries that can be used from the setup() function if it is installed. This means that all installation should be local installations.

Therefore, I would like to collect some examples of how people install things on windows and how it could be done with this kind of procedure, and what kind of utilities we would need to provide to make this ergonomic. Privilege escalation should not be required.

I want to suppress warning messages.

Problems summary

A warning message is displayed.

Expected

I want to suppress warning messages.

Environment Information

  • nvim-lsp version (SHA1): 7a15a52

  • deoplete-lsp version (SHA1): 7a8c44f423bc4339c092a759abaad40131d2c98a

  • deoplete version (SHA1): 5be25591770c5abc7214e8899c4d451c479ac2ec

  • OS: Mac

  • neovim/Vim :version output: NVIM v0.5.0-316-g8fe0635e7

Plugins and settings

[[plugins]]	
repo = 'Shougo/deoplete.nvim'	
hook_add = ''' 	
call deoplete#custom#var('omni', 'input_patterns', {
    \ 'rust': '(\.|::|->)\w',
    \})

call deoplete#custom#option('sources', {
    \ 'rust': ['lsp'],
    \})
   
call deoplete#custom#source('_', 'converters', [
    \ 'converter_remove_paren',
    \ 'converter_remove_overlap',
    \ 'matcher_length',
    \ 'converter_truncate_abbr',
    \ 'converter_truncate_info',
    \ 'converter_truncate_menu',
    \ 'converter_auto_delimiter',
    \])

set completeopt-=preview

call deoplete#enable()	
'''

[[plugins]]
repo = 'Shougo/deoplete-lsp'	

[[plugins]]
repo = 'neovim/nvim-lsp'
hook_add = '''
    command! Scratch lua require'lsp'.makeScratch()
'''

.config/nvim/lua/lsp.lua

-- 
local api = vim.api
local M = {}
function M.makeScratch()
    require'nvim_lsp'.rls.setup{}
end
return M

How to reproduce the problem from neovim startup

  1. $ cargo new issue-rust
  2. $ cd issue-rust
  3. $ nvim
  4. :Scratch
  5. :e src/main.rs
  6. Type appropriately

スクリーンショット 2020-01-18 15 03 51

gopls "reply not invoked with a valid call"

Set my entire Neovim config to:

call lsp#set_log_level("debug")

call lsp#add_filetype_config({
      \ 'filetype': 'go',
      \ 'name': 'gopls',
      \ 'cmd': 'gopls'
      \ })

autocmd Filetype go setl omnifunc=lsp#omnifunc

I get this error when opening a Go source file:

LSP[id=1] client has shut down after sending the message
LSP[id=1] 2019/11/13 14:27:32 : reply not invoked with a valid call

This error (as far as I can tell) comes from: https://github.com/go-language-server/jsonrpc2/blob/master/jsonrpc2.go#L334

Setting root_dir to the project dir has no effect.

Running gopls with verbose and logging:

      \ 'cmd': 'gopls -v -logfile gopls.log'

Just writes an empty log.

Other details:

go version: go version go1.13.4 darwin/amd64
gopls version: golang.org/x/tools/gopls 0.2.0
    golang.org/x/tools/[email protected] h1:ddCHfScTYOG6auAcEKXCFN5iSeKSAnYcPv+7zVJBd+U=

Working coc.nvim config, for reference:

{
  "languageserver": {
    "golang": {
      "command": "gopls",
      "args": [],
      "rootPatterns": [
        "go.mod",
        ".vim/",
        ".git/",
        ".hg/"
      ],
      "filetypes": [
        "go"
      ]
    }
  }
}

When invoked from coc.nvim, lsof -p <pid> | grep cwd reveals the CWD of gopls is the project directory.

Switch root patterns to `or os_homedir()` by default?

I realized something from some recent PRs, which is that if you want to allow a Language Server for single files not in a project, we can just return homedir, and use the root_pattern/existing mechanism for everything else.

Basically, we should probably do this for most/all servers:

root_dir = function(fname)
  return nvim_lsp.util.find_git_ancestor(fname) or vim.loop.os_homedir()
end;

Where single files will use the homedir instance of the client.

question: more information with reference/implementation results

Hi,

Is there a way to configure nvim-lsp to show the line contents as well as the file:line:column in the quickfix?

At least by default, it seems to only show the filename information, which makes it quite hard to go where I need, since I don't know what is at those positions.

Change installation scripting to use native Lua commands

I had a thought today that I could provide a function to make this easier which looks like this:

util.script(function(sh, print)
  sh.curl{"https://..."}
  sh.julia({}, {stdout = function()...end; onexit=...})
  print("ASLKDJLAKSJD")
end)

This would allow us to choose how to implement the backend and abstract it away, for instance by redirecting the output of the commands to a buffer (like we do currently with util.sh) and still make it ergonomic to use.

I already have a prototype I use for my own things which has the interface I'm describing above, and I've found it very useful in practice. We could even use luv (with coroutines to synchronize execution) instead of vim.fn.system to execute things to avoid some overhead, but that may also just be overoptimizing and we can return the output each time anyway.

This would also probably be a useful utility to go in neovim core too.

Enter all keywords and they will be removed from completion.

Problems summary

Enter all keywords and they will be removed from completion.

Expected

Even if you enter all keywords, do not disappear from the completion candidates.

Environment Information

  • nvim-lsp version (SHA1): 7a15a52

  • deoplete-lsp version (SHA1): 7a8c44f423bc4339c092a759abaad40131d2c98a

  • deoplete version (SHA1): 5be25591770c5abc7214e8899c4d451c479ac2ec

  • OS: Mac

  • neovim/Vim :version output: NVIM v0.5.0-324-gef379d4ea

Plugins and settings

[[plugins]]	
repo = 'Shougo/deoplete.nvim'	
hook_add = ''' 	
call deoplete#custom#var('omni', 'input_patterns', {
    \ 'rust': '(\.|::|->)\w',
    \})

call deoplete#custom#option('sources', {
    \ 'rust': ['lsp'],
    \})
   
call deoplete#custom#source('_', 'converters', [
    \ 'converter_remove_paren',
    \ 'converter_remove_overlap',
    \ 'matcher_length',
    \ 'converter_truncate_abbr',
    \ 'converter_truncate_info',
    \ 'converter_truncate_menu',
    \ 'converter_auto_delimiter',
    \])

set completeopt-=preview

call deoplete#enable()	
'''

[[plugins]]
repo = 'Shougo/deoplete-lsp'	

[[plugins]]
repo = 'neovim/nvim-lsp'
hook_add = '''
    command! Scratch lua require'lsp'.makeScratch()
'''

.config/nvim/lua/lsp.lua

-- 
local api = vim.api
local M = {}
function M.makeScratch()
    require'nvim_lsp'.rls.setup{}
end
return M

How to reproduce the problem from neovim startup

  1. $ cargo new issue-rust
  2. $ cd issue-rust
  3. $ nvim
  4. :Scratch
  5. :e src/main.rs
  6. Type appropriately

In this example, typing st leaves str as a completion candidate, but typing str removes str from the completion candidates.
スクリーンショット 2020-01-25 1 54 04

スクリーンショット 2020-01-25 1 54 24

In VSCode, completion candidates remain.
スクリーンショット 2020-01-25 1 58 18

omni completion results duplicate $ character

When triggering omni completion CTRL-X_CTRL-O on the $ character, all matches will ignore the first $ and duplicate it. For example, when using the intelephense LS, if I trigger omni completion it will result in $$GLOBALS. The expected behavior is $GLOBALS.

lazy load configs

I've tried to configure nvim-lsp in a similar way I do coc. I try to avoid loading the plugin unless I'm in a file type that uses it. Here is what I'm doing right now:

" In plugin/lsp.vim
autocmd FileType python,rust call config#lsp#init()

" In autoload/config/lsp.vim
function! config#lsp#init() abort
      packadd nvim-lsp
      nnoremap <silent> ;dc <cmd>lua vim.lsp.buf.declaration()<CR>
      nnoremap <silent> ;df <cmd>lua vim.lsp.buf.definition()<CR>
      nnoremap <silent> ;h  <cmd>lua vim.lsp.buf.hover()<CR>
      nnoremap <silent> ;i  <cmd>lua vim.lsp.buf.implementation()<CR>
      nnoremap <silent> ;s  <cmd>lua vim.lsp.buf.signature_help()<CR>
      nnoremap <silent> ;td <cmd>lua vim.lsp.buf.type_definition()<CR>
    if &filetype ==# 'rust'
        lua require'nvim_lsp'.rust_analyzer.setup{}
    elseif &filetype ==# 'python'
        lua require'nvim_lsp'.pyls_ms.setup{ log_level = 2 }
    endif
    setlocal omnifunc=v:lua.vim.lsp.omnifunc
endfunction

I think the reason this doesn't work is because nvim-lsp is setting filetype autcmds. Is there a way to do what I want?

If I put nvim-lsp in the start package directory, it doubles my vim load time, so I really don't want to load it unless I need it.

Add support for settings schema from VSCode package.json

https://github.com/rust-lang/rls-vscode/blob/master/package.json
https://github.com/lampepfl/dotty/blob/master/vscode-dotty/package.json
https://github.com/mauve/vscode-terraform/blob/master/package.json

There is a very simple part of the existing VSCode extensions that we can automatically adopt by parsing contributes.configuration. There are other sections that we can get as well.

I'm considering adding this to docs just for auto generating documentation about what the default settings are, but we could use the same schema to provide client side validation of the settings as well.

So currently, I think this will be sufficient:

docs = {
  package_json = "https://github.com/rust-lang/rls-vscode/blob/master/package.json";
}

and then we can pull it from docgen (and cache it in case it hasn't changed).

Also, we can put these in the

Default server settings:
nvim_lsp[server].setup {
  settings = {
    ...
  }
}

since these settings will often be long.

lua lsp docs should be expanded

Right now, trying to configure the lua lang-server is a bit difficult. It's not clear the best way to customize things based on someones machine/env.

Internal private language server at work

Hi, I have a language server that is private and internal at work, and not open-source.

Is there a straightforward way I can create a definition in my private files and load it into nvim-lsp all the same, so I don't have to contribute to this repo and leak internal information? Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.