erg-lang / erg-language-server

An Erg compiler frontend for IDEs, implements LSP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Adding server configurations to nvim-lspconfig

pysan3 opened this issue · comments

Hi,

I recently came across this programming language and really love what the language provides.

I want to add a configuration file for els to set it up for neovim with the nvim-lspconfig plugin.
Here is the current state of the configuration file.

I was wondering what would be a suitable way to detect the path to the current project.
i.e. we should provide a function to default_config.root_dir in the configuration file.

Here are some tricks people use for other languages.

  • util.find_git_ancestor
    • Find the nearest .git/ from ancestors (parent directories).
  • util.root_pattern('<file-name>')
    • Find the '<file-name>' in parent directories.
  • util.search_ancestors(func)
    • Provide a func that returns true given the absolute path of each ancestor.

For example, the config file for rust_analyzer does something like this. (or is like a fallback)

util.root_pattern('Cargo.toml') \
or [Search 'workspace_root' from `cargo metadata --no-deps`] \
or util.root_pattern('rust-project.json') \
or util.find_git_ancestor()

I read the Package System section in the documentation but was not sure what to look for and whether this was a strict language specification or not.

Could you provide me with some ideas?

Thanks in advance,
@pysan3

The specifications for the package manager can be found here.

https://github.com/erg-lang/erg/blob/main/doc/EN/tools/pack.md

I have not implemented the package manager yet, but I plan to use package.er as the file equivalent to Cargo.toml in cargo.

Thank you for providing me the page.

I think I will go with the following setup for now.

util.root_pattern('package.er') \
or util.find_git_ancestor()

I can't wait for this project to take off. Keep up with your hard work!

EDIT: PR to nvim-lspconfig -> neovim/nvim-lspconfig#2165