Skip to content

Language server not working in seperate source directory. (Using neovim) #395

@yoghurt-x86

Description

@yoghurt-x86

I have a elm.json with two source-directories that looks like:

{
    "type": "application",
    "source-directories": [
        "src",
	"../lib"
    ],
    "elm-version": "0.19.1",
    "dependencies": {
        "direct": {
            "elm/browser": "1.0.2",
            "elm/core": "1.0.5",
            "elm/html": "1.0.0",
            "elm/http": "2.0.0",
            "elm/json": "1.1.3"
        },
        "indirect": {
            "elm/bytes": "1.0.8",
            "elm/file": "1.0.5",
            "elm/time": "1.0.0",
            "elm/url": "1.0.0",
            "elm/virtual-dom": "1.0.2"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

Here is a picture of the directory structure.
image

I am using neovim 0.5.0 with the build-in LSP client and elmls config from neovim/nvim-lspconfig
It works as expected in normal projects, i can see warnings and jump to definitions and such, but if i open a file in a source directory like ../lib there is no lsp functionality

If i open Main.elm there is no issues. I can see warning and jump to definitions and such.
With Main.elm open in the current buffer and i run:
:lua print(vim.inspect(vim.lsp.buf_get_clients()))
I get a bunch of output.

If i jump to ../lib/CustomLib.elm and run the same command i get no output.
So it looks like the LSP client isn't attached?

If i instead move the directory ../lib inside the elm project (next to src) then it will work as expected.
But in my case i want multiple elm projects to share the same lib.

Is it possible to get the LSP client to attach in another source directory outside the elm project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions