I'm trying to configure nvim as an replacement for VSCode an VS2022. I've managed to make autocompletion to work, but it seems to be compiling my code using an older language version (I'm using language version 10), so my code it's been marked with many errors, although it compiles correctly with 'dotnet build'.
I'm not sure if thats a problem with Roslyn or LSP so not sure where should I look for more information.
I've tried with both omnisharp and csharp-ls as LSP servers (installed through nvim-lsp-installer) an both report the same errors.
The plugins i'm using are:
Plug 'mfussenegger/nvim-dap'
Plug 'williamboman/nvim-lsp-installer'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-lua/completion-nvim'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'OmniSharp/omnisharp-vim'
Plug 'dense-analysis/ale'
Plug 'mattn/emmet-vim'
Plug 'tpope/vim-commentary'
Plug 'Yggdroot/indentLine'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree'
Plug 'ryanoasis/vim-devicons'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-telescope/telescope.nvim'
This is the configuration of the lsp servers:
require'lspconfig'.csharp_ls.setup{}
require'lspconfig'.omnisharp.setup {
capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = function(_, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
end,
cmd = { "~/.cache/omnisharp-vim/omnisharp-roslyn/run", "--languageserver" , "--hostPID", tostring(pid) },
}
The following images shows that with both charp-ls and with omnisharp I get an error at the var keyword in line 3, because it's not recognising the feature of C# 9 that allows to write top level statements. I tryed to explicitly specify the LangVersion at the csproj file, but the results where the same.