Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playing around with Neovim 0.5 LSP and fsharp-language-server #82

Open
PhilT opened this issue Sep 28, 2020 · 5 comments
Open

Playing around with Neovim 0.5 LSP and fsharp-language-server #82

PhilT opened this issue Sep 28, 2020 · 5 comments

Comments

@PhilT
Copy link

PhilT commented Sep 28, 2020

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 (neovim/neovim#13001) it works! I get completion, errors, symbols, etc.

@jubnzv
Copy link

jubnzv commented Oct 26, 2020

@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.

@PhilT
Copy link
Author

PhilT commented Oct 26, 2020

You'll need the code from the PR that I raised above (neovim/neovim#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

@jubnzv
Copy link

jubnzv commented Oct 27, 2020

@PhilT It started working after applying your patch.

Thank you very much! :)

image

@PhilT
Copy link
Author

PhilT commented Nov 2, 2020

@jubnzv Commit neovim/neovim#13174 means the patch is no longer required and works with the latest Neovim 0.5 master.

@jubnzv
Copy link

jubnzv commented Nov 3, 2020

@PhilT Thanks, yes, it works. There are some problems with nvim-lsp in neovim's HEAD (neovim/neovim#13210), but earlier versions works well with fsharp-lsp-server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants