Spawning language server with cmd`diagnostic-languageserver`failed. The language server is either not installed, missing from PATH, or not executable - neovim

enter image description here
" Spawning language server with cmd: diagnostic-languageserver failed. The language server is either not installed, missing from PATH, or not executable "
nvim problem
i copied devaslife's dotfiles and installed plugin
yesterday it work, but today i entered LSP info after that when i Enter shows that the error

I've resolved this problem by executing the below command
npm install -g diagnostic-languageserver

Use this:
yarn global add diagnostic-languageserver

Probably, it's because you have not set up the right programming language that you are using in the lspconfig.rc.vim, precisely in the nvim_lsp.tsserver.setup part.
I had the same problem because I was in javascript file (.js) and the lsp config that I was using from someone else only supports typescript files. So, I just had to add the javascript, javascriptreact and javascript.jsx. For example :
nvim_lsp.tsserver.setup {
on_attach = on_attach,
filetypes = { "typescript", "typescriptreact", "typescript.tsx", "javascript", "javascriptreact", "javascript.jsx" },
capabilities = capabilities
}

That is not working for me. In the lspconfig.re.vim, i had to delete the "javascipt", "javasriptreact", "javascript.jsx" types from the nvim_lsp.diagnosticls.setup/filetypes, and then put them in the nvim_lsp.tsserver.setup>filetypes

For windows you can use this:
nvim_lsp.tsserver.setup {
on_attach = on_attach,
filetypes = { "typescript", "typescriptreact", "typescript.tsx" },
cmd = { "typescript-language-server.cmd", "--stdio" }
}
This will make sure it will run the .cmd file that is along side the .ps1.

Related

mason lsp pyright seems to be download but dosen't work on vim

I have a problem on my nvim LSP.
according to mason plugin the pyright is downloaded and I on other IDE the lsp works great.
when i open python file with neovim it didn't recognized import and basic functions.
someone can handle this situation?
maybe it's because Lspinfo tell me that it didn't get the python root directory?import don't auto complete pythonpyright is downloaded via masonLSPInfo description
on other languages it works so don't really understand the problem
Same as me, at the moment I solved like this (it happens in some languages for me too):
local status_ok, mason = pcall(require, "mason")
if not status_ok then
return
end
local status_masonlsp_ok, mason_lspconfig = pcall(require, "mason-lspconfig")
if not status_masonlsp_ok then
return
end
local servers = {
"sumneko_lua",
"rust_analyzer",
"tailwindcss",
"bashls",
"pyright",
-- "csharp_ls",
"html",
"omnisharp",
"gopls",
}
mason.setup(settings)
mason_lspconfig.setup({
ensure_installed = servers,
automatic_installation = true,
})
So when I open nvim they are installed automatically.

Why pyright config with mason in nvim shows that package is not accessed

The pyright did not run well:
Although it completes properly, it cannot find the package location:
This is my config for pyright
--config python language server
lspconfig["pyright"].setup({
capabilities = capabilities,
on_attach = on_attach,
settings={
python = {
pythonPath="/usr/bin/python3"
},
pyright = {}
}
})
I hope someone can help me to fix the not accessed issue, I did not find a good solution on google.

How to apply multiple auto fixes with nvim LSP

In nvim, using LSP, i want to be able to apply a 'fix all of the same type' similar to what can be done in VSCode (see picture). How would one go about adding this to LSP code actions?
Edit: I know this can be done using COC. But i want it for LSP.
It depends on the language server you are using, in my current NeoVim configuration I'm running both ESLint and tsserver and with a default configuration of ESLint in my root of my project, I get these types of code action.
Assuming you are using lspconfig plugin you need to make sure you have the server configured :
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require('lspconfig')['tsserver'].setup {
on_attach = function() end,
capabilities = capabilities,
}
require('lspconfig')['eslint'].setup {
on_attach = function() end,
capabilities = capabilities,
}
You can then run in neovim : :lua vim.lsp.buf.code_action() in command mode (n)
You need both LSP installed manually
Ref :
https://github.com/neovim/nvim-lspconfig#quickstart
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#eslint
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#tsserver
N.B. You should probably add your keymap related to LSP in the on_attach callback

How do I setup elixir-ls using nvim-lspconfig with autocompletion in neovim?

I would like to set up the Elixir language server in Neovim using the built-in language server client and nvim-lspconfig.
Documentation for this seems to be spread out in multiple places:
nvim-lspconfig README
nvim-lspconfig wiki about autocomplete
nvim-lspconfig elixir-ls server configuration documentation
elixir-ls installation instructions
I am a little overwhelmed and have made multiple attempts to do this, but always give up without success. I also found a useful looking guide: How to Set Up Neovim for Elixir Development, but it makes quite a few assumptions, seems to eroneously do some configuration twice, and also switches config format halfway through, so wasn't a usable summary for me (after following the instructions, documentation popups were not working, and I was unable to scroll inside the autocomplete popups - I also had a lot of copy/pasted config I didn't understand).
So far I understand the required steps are:
Install neovim
Install elixir-ls manually (it doesn't seem to be possible currently to install via asdf due to a lack of ability to ask elixir-ls for its version)
Install required neovim plugins: nvim-lspconfig + whatever is required for autocomplete
Set up necessary config for nvim-lspconfig and autocomplete.
I have managed to do up to part-way through step 3, but have not sucesfully worked out the required dependencies and configuration for autocomplete.
What do I need to do to have a working elixir-ls setup in neovim, with autocomplete, using nvim-lspconfig and neovim's built-in language server client?
I managed to get everything working with the combination of some plugins for completion in neovim. They are:
hrsh7th/nvim-cmp - the autocompletion plugin
hrsh7th/cmp-nvim-lsp - the integration of nvim-cmp with neovim's LSP
L3MON4D3/LuaSnip - a snippets plugin
saadparwaiz1/cmp_luasnip - the snippets source for nvim-cmp
This is the same list of plugins from the nvim-cmp recommendation of neovim's Wiki.
I'm using packer to manage the plugins. I'm also installing the plugins before configuring them.
Here is the installation lines:
use 'neovim/nvim-lspconfig'
use 'nvim-treesitter/completion-treesitter' -- Only if you are using TS
use 'hrsh7th/nvim-cmp' -- Autocompletion plugin
use 'hrsh7th/cmp-nvim-lsp' -- LSP source for nvim-cmp
use 'saadparwaiz1/cmp_luasnip' -- Snippets source for nvim-cmp
use 'L3MON4D3/LuaSnip' -- Snippets plugin
And then the configuration part:
-- Add additional capabilities supported by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
-- Configure ElixirLS as the LSP server for Elixir.
require'lspconfig'.elixirls.setup{
cmd = { "/home/my-user/path-to/elixir-ls/release/language_server.sh" },
-- on_attach = custom_attach, -- this may be required for extended functionalities of the LSP
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
},
elixirLS = {
dialyzerEnabled = false,
fetchDeps = false,
};
}
local luasnip = require 'luasnip'
-- nvim-cmp
local cmp = require 'cmp'
cmp.setup {
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
['<Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end,
['<S-Tab>'] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end,
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
},
}
You can find all my neovim config in my dotfiles repo: https://github.com/philss/dotfiles
For reference, here is the nvim version I'm using (installed from source):
NVIM v0.7.0-dev+864-g2818de8b7
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Features: +acl +iconv +tui
In addition to the accepted answer, I suggest installing language server via Homebrew or similar instead of cloning repo and compiling. Philip's answer is correct. Just make your life easier by using a package manager for language server installation.
If you use LunarVim, which is like a NeoVim IDE, the configuration is minimal.
Nearly all dependencies for completion are already installed.
I also found it is better for Mac users to use Homebrew to install Elixir Language Server like so:
brew install elixir-ls
You don't need to keep track of the updates manually. It is usually upgraded along with other dev dependencies via brew update && brew upgrade.
Try this for LunarVim:
-- generic LSP settings
--
-- ---#usage disable automatic installation of servers
-- lvim.lsp.automatic_servers_installation = false
local lspconfig = require("lspconfig")
-- Neovim doesn't support snippets out of the box, so we need to mutate the
-- capabilities we send to the language server to let them know we want snippets.
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!!
-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))`
-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" })
-- local opts = {} -- check the lspconfig documentation for a list of all possible options
-- require("lvim.lsp.manager").setup("pyright", opts)
-- Elixir LS
lspconfig.elixirls.setup {
cmd = { "/usr/local/Cellar/elixir-ls/0.10.0/libexec/language_server.sh" },
-- on_attach = custom_attach, -- this may be required for extended functionalities of the LSP
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
},
elixirLS = {
dialyzerEnabled = false,
fetchDeps = false,
};
}

Installing an exe with Powershell DSC Package resource gets return code 1619

I'm trying to use Powershell DSC's Package resource to install an exe... Perforce's P4V to be specific. Here's my code:
Configuration PerforceMachine
{
Node "SERVERNAME"
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "\\nas\share\p4vinst64.exe"
ProductId = ''
Arguments = "/S /V/qn" # args for silent mode
LogPath = "$env:ProgramData\p4v_install.log"
}
}
}
When running this, this is the error Powershell gives me:
PowerShell provider MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1619 was not expected. Configuration is likely not
correct
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : SERVERNAME
According to documentation, return code 1619 means the MSI package couldn't be opened. However, when I manually log in to the machine and run "\\nas\share\p4vinst64.exe /S /V/qn", the install works flawlessly.
Does anyone know why this is failing? Alternately, can anyone tell me how to troubleshoot this? I pasted all the error information I got from the terminal, my log file (p4v_install.log) is a 0 byte file, and there are no events in the event viewer. I don't know how to troubleshoot it any further!
EDIT: I should note that I also tried using the File resource to copy the file locally, and then install it from there. Sadly, that met with the same result.
Daniel over at the Powershell.org forums was able to figure this out for me.
The P4V InstallShield setup wrapper puts the MSI file into wrong path if you execute as LocalSystem.
I’ve managed to develop a Configuration that works, see below. The key is the /b switch here which puts the MSI file into a defined location. I’ve added ALLUSERS=1 to get the shortcuts visible to all users and REBOOT=ReallySuppress to avoid a sudden restart (which will happen otherwise).
Configuration PerforceMachine
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "C:\My\p4vinst64.exe"
ProductId = ''
Arguments = '/b"C:\Windows\Temp\PerforceClient" /S /V"/qn ALLUSERS=1 REBOOT=ReallySuppress"' # args for silent mode
}
}
Well, what happens here is that the package gets installed (not tested with p4vinst64.exe yet! So, not sure why it says pack cannot be opened as the error) but since you did not specify a ProductID value, the verification at the end of install fails. That is the error you are seeing. The Package resource is no good for installing .exe packages or even MSIs with no ProductID represented as a GUID.
You can use the WindowsProcess resource instead.