nextflow-io / language-server

The Nextflow language server
Apache License 2.0
9 stars 0 forks source link

Support of other Text editors #56

Open edmundmiller opened 2 weeks ago

edmundmiller commented 2 weeks ago
### Emacs
- [ ] https://github.com/emacs-lsp/lsp-mode/pull/4606
- [ ] Elgot
### Neovim
- [ ] https://github.com/mason-org/mason-registry/pull/7480
- [ ] https://github.com/neovim/nvim-lspconfig/pull/3423
- [ ] https://github.com/williamboman/mason-lspconfig.nvim/pull/486
mehalter commented 2 weeks ago

I have a branch of nvim-lspconfig that adds Nextflow support that works and makes sure there is the one necessary setting set (nextflow.files.exclude): https://github.com/mehalter/nvim-lspconfig/commit/873ef31beee09f10554676dcd1dea4c9ed9e7c1e

The contribution guidelines indicate that a language server repo needs to have 100+ stars to be added to avoid bloat of short lived/not very used language servers being added into the codebase. I will keep an eye out and open the PR there when it's appropriate. Here is a minimal code block that can be added to a Neovim configuration to manually add the language server until then:

-- Hot patch nvim-lspconfig to add Nextflow language server
require("lspconfig.configs").nextflow_ls = {
  default_config = {
    cmd = { "java", "-jar", "nextflow-language-server-all.jar" },
    filetypes = { "nextflow" },
    root_dir = function(fname)
      local util = require("lspconfig.util")
      return util.root_pattern('nextflow.config')(fname) or util.find_git_ancestor(fname)
    end,
    settings = {
      nextflow = {
        files = {
          exclude = { ".git", ".nf-test", "work" },
        },
      },
    },
  },
}

-- Set up the Nextflow language server like any other language server
-- (once the language server is added upstream, this will be the only code necessary)
require("lspconfig").nextflow_ls.setup {
  capabilities = vim.lsp.protocol.make_client_capabilities(),
  -- on_attach = function(client, bufnr) end, -- set up on attach function
}
edmundmiller commented 2 weeks ago

@mehalter Could we use the stars from https://github.com/nextflow-io/vscode-language-nextflow in that case? 😆

It's a pretty small community, the VS Code extension only has 27K Downloads. So completly understand if that's never going to get merged in because it's too small and might not get maintained.

mehalter commented 2 weeks ago

Also worth noting for users that use AstroNvim there is a community language pack for Nextflow that does most of this boiler plate as well as adds syntax highlighting, filetype detection, and icons for the filetype. This can be added easily for those users as well.

The link to the language pack has the instructions for setting it up, but the gist comes down to in your AstroNvim configuration you need to:

  1. Add the Nextflow pack to your list of community extensions (the users's community.lua file):
{ import = "astrocommunity.pack.nextflow" }
  1. Add installation details for where you installed the Nextflow language server .jar file (goes into the user's plugins/ folder such as plugins/nextflow_ls.lua):
return {
  "AstroNvim/astrolsp",
  opts = {
    -- This line enables the setup of the Nextfow language server
    servers = { "nextflow_ls" },
    configs = {
      -- Must set the command with the path to your JAR file
      nextflow_ls = {
        cmd = { "java", "-jar", "<path to language-server-all.jar>" },
      },
    },
  },
}

(Once this gets added to Mason and lspconfig then all the user would have to do is step 1 and it will handle installing and setting up the language server, I'll update this comment once that happens)

mehalter commented 2 weeks ago

That's a good question, plus this is an official language server of the language's organization so that probably helps rather than it being a personal project. I'll open the PR and see what they say and mention it's the officially supported language stuff. If they bounce it back then I'll just keep an eye out and keep on pressing!

mehalter commented 2 weeks ago

@edmundmiller opened a PR here: https://github.com/neovim/nvim-lspconfig/pull/3423

Fingers crossed! Glad to see this modernization happening!

edmundmiller commented 2 weeks ago

Awesome, thank you so much for making that all happen! I'll have to try out the AstroNvim language pack now!

mehalter commented 2 weeks ago

@edmundmiller the neovim lspconfig PR I opened for merged in! Thanks for linking me the vs code download count! That was a valid metric for vetting the language server :)