Robert's Homepage

Troubleshoot - Neovim LSP Not Working for Language

#neovim #lsp

Pre-requisites:

Debug

For example the gopls.lua configuration:

# gopls.lua

# -- snipped --


default_config = {
	root_dir = [[root_pattern("go.mod", ".git")]],
},

The above configuration depends on the presence of a go.mod or .git file in the current working directory order to detect and activate the LSP. If you are not seeing autocomplete suggestions, check that these files are available in your buffer’s current working directory (:pwd).

Neovim code snippet with dropdown menu autocomplete suggestion functions for go using gopls

Figure 1: A dropdown menu showing autocomplete suggestions for go using gopls.

Here is another example for the solargraph.lua configuration

# solargraph.lua
# --snipped--

default_config = {
	root_dir = [[root_pattern("Gemfile", ".git")]],

},

Similar to gopls, the solargraph configuration looks for a Gemfile or .git file in the current working directory. If it detects one, it will activate the LSP.