PMunch / nimlsp

Language Server Protocol implementation for Nim
MIT License
416 stars 50 forks source link

Neovim LSP Error: cannot open '/tmp/nimlsp-testproject/lib/system.nim'\n" #98

Closed flosker closed 2 years ago

flosker commented 2 years ago

nimlsp looks for system.nim inside project folder. This is my lsp config

-- Nim
nvim_lsp.nimls.setup {
    cmd          = { 'nimlsp', '.' },
    filetypes    = { 'nim' },
    single_file_support = true,
    root_dir     = lsp.root_dir, -- .git folder
}

Am I doing something wrong?

flosker commented 2 years ago

Solved it by adding this config to config/nim.cfg

--lib:"/usr/lib/nim"
PMunch commented 2 years ago

Your real problem is that you're passing . to nimlsp according to nimlsp --help:

Usage: nimlsp [OPTION | PATH]

--help, shows this message
--version, shows only the version
PATH, path to the Nim source directory, defaults to "/home/peter/.choosenim/toolchains/nim-1.4.0"

That default value is set on compile-time to the path where the Nim you're compiling with resides. When you pass . it will resolve that to be your current path.

Judging by --lib:"/usr/lib/nim" however it seems like you may have installed Nim via your package manager. This is generally discouraged as package managers tend to have very outdated versions of Nim and some tools might misbehave. I'd recommend grabbing choosenim either from your package manager or directly. It allows you to easily switch to the newest version of Nim very easily, and it allows you to jump between versions if you need to.

flosker commented 2 years ago

path to the Nim source directory

I thought it meant project's (written in nim) source directory. At my end it shows defaults to /usr.

I've fixed my config though! And now I don't need --lib:"/usr/lib/nim" either.