fsharp-language-server
fsharp-language-server copied to clipboard
Playing around with Neovim 0.5 LSP and fsharp-language-server
FYI, I've been messing around trying to get Neovim nightly's LSP working with fsharp-language-server and I'm happy to report that with some tweaking (https://github.com/neovim/neovim/pull/13001) it works! I get completion, errors, symbols, etc.
@PhilT Hi, I'm trying to use fsharp-language-server with nvim-lsp too, but not sure, why it doesn't work.
Could you share your configuration, please?
I created the following configuration, which seems correct for me:
local configs = require 'nvim_lsp/configs'
local util = require 'nvim_lsp/util'
configs.fsharp_language_server = {
default_config = {
-- Path to binary created with `dotnet publish -c Release -r linux-x64 src/FSharpLanguageServer`.
-- I also tried to use cmd for `dotnet exec $path/FSharpLanguageServer.dll`.
-- Both solutions work well from the command line.
cmd = {"/home/jubnzv/Sources/fsharp-language-server/src/FSharpLanguageServer/bin/Release/netcoreapp3.0/FSharpLanguageServer",};
filetypes = {'fsharp',};
root_dir = util.root_pattern(".git");
};
docs = {
description = [[
https://github.com/fsprojects/fsharp-language-server
This project is an implementation of the language server protocol using the F# Compiler Service.
]];
default_config = {
root_dir = [[root_pattern(".git")]];
};
};
}
This is somewhat strange, since I don't get any errors in lsp logs and I also can execute fsharp-language server directly.
You'll need the code from the PR that I raised above (https://github.com/neovim/neovim/pull/13001).
Here is Lua config in init.vim
:lua << END
local nvim_lsp = require 'nvim_lsp'
local configs = require 'nvim_lsp/configs'
configs.fsharp = {
default_config = {
cmd = {"dotnet", "/home/phil/code/fsharp-language-server/src/FSharpLanguageServer/bin/Release/netcoreapp3.1/FSharpLanguageServer.dll"};
filetypes = {"fsharp"};
root_dir = nvim_lsp.util.root_pattern("*.fsproj", ".git");
};
}
local nvim_command = vim.api.nvim_command
local on_attach = function(client, bufnr)
require'completion'.on_attach{}
require'diagnostic'.on_attach{}
nvim_command('autocmd CursorHold <buffer> lua vim.lsp.util.show_line_diagnostics()')
end
nvim_lsp.fsharp.setup{on_attach = on_attach}
nvim_lsp.tsserver.setup{}
END
Shout if you need some more direction on setting it up.
Cheers, Phil
@PhilT It started working after applying your patch.
Thank you very much! :)
@jubnzv Commit https://github.com/neovim/neovim/pull/13174 means the patch is no longer required and works with the latest Neovim 0.5 master.
@PhilT Thanks, yes, it works. There are some problems with nvim-lsp in neovim's HEAD (https://github.com/neovim/neovim/issues/13210), but earlier versions works well with fsharp-lsp-server.