hansec / fortran-language-server

Fortran Language Server for the Language Server Protocol
MIT License
294 stars 57 forks source link

Fortls not getting the root_dir #208

Closed TheGreatDeadOne closed 2 years ago

TheGreatDeadOne commented 2 years ago

Thank you very much for FLS and its support in Neovim/Vim!

I installed the server using pip, and the binary installation folder is already in the $PATH (~/.local/bin), but it looks like when the binary is run on neovim, fortls is not identifying the root_dir.

$ fortls --debug_rootpath /var/home/gabriel/

Testing "initialize" request:
  Root = "/var/home/gabriel/"
  Succesful!

  Source directories:
    /var/home/gabriel/Documentos/Universidade/Física Computacional/Atividades

Obs: I use Fedora Silverblue, that's why var/home is linked to /home

But when I check the server and client status in :Lspinfo on Neovim, I get the following output:

Language client log: /var/home/gabriel/.var/app/io.neovim.nvim/cache/nvim/lsp.log
 Detected filetype:   fortran

 0 client(s) attached to this buffer: 

 Other clients that match the filetype: fortran

 Config: fortls
    filetypes:         fortran
    root directory:    NA (problem here)
    cmd:               fortls
    cmd is executable: true
    autostart:         true
    custom handlers:   

 Configured servers list: fortls, pyright, bashls
eamousing commented 2 years ago

This is due to the way lspconfig determines the root directory which is specified in:

~/.config/nvim/plugged/nvim-lspconfig/lua/lspconfig/fortls.lua

You have at least two options: 1) add a project configuration json file called .fortls in your project folder (see https://github.com/hansec/fortran-language-server)

or

2) add '.git' in fortls.lua, i.e., root_dir = util.root_pattern('.git', '.fortls')

Then initialise a git repo in the project folder (if not already done) with git init

After this, the root directory should be available

TheGreatDeadOne commented 2 years ago

This is due to the way lspconfig determines the root directory which is specified in:

~/.config/nvim/plugged/nvim-lspconfig/lua/lspconfig/fortls.lua

You have at least two options:

1. add a project configuration json file called .fortls in your project folder (see https://github.com/hansec/fortran-language-server)

or

1. add '.git' in fortls.lua, i.e.,
   root_dir = util.root_pattern('.git', '.fortls')

Then initialise a git repo in the project folder (if not already done) with git init

After this, the root directory should be available

Thanks, that was pretty simple!