Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of other Text editors #56

Open
2 of 5 tasks
edmundmiller opened this issue Nov 6, 2024 · 10 comments
Open
2 of 5 tasks

Support of other Text editors #56

edmundmiller opened this issue Nov 6, 2024 · 10 comments

Comments

@edmundmiller
Copy link

edmundmiller commented Nov 6, 2024

Emacs

Preview Give feedback
  1. client documentation

Neovim

Preview Give feedback

Others:

@mehalter
Copy link

mehalter commented Nov 6, 2024

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): mehalter/nvim-lspconfig@873ef31

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
Copy link
Author

@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
Copy link

mehalter commented Nov 6, 2024

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
Copy link

mehalter commented Nov 6, 2024

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
Copy link

mehalter commented Nov 6, 2024

@edmundmiller opened a PR here: neovim/nvim-lspconfig#3423

Fingers crossed! Glad to see this modernization happening!

@edmundmiller
Copy link
Author

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

@mehalter
Copy link

mehalter commented Nov 7, 2024

@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 :)

@tesujimath
Copy link

tesujimath commented Nov 29, 2024

FYI Helix is working nicely, see pointers in #82

If you're not interested in all the Nix stuff, once you have a wrapper script called nextflow-language-server on your path, these additions I made in Helix languages.toml should get you started (updated):

[[language]]
file-types = ["nf", "nf.test", {glob = "nextflow.config"}]
language-servers = ["nextflow-language-server"]
name = "nextflow"
scope = "source.nextflow"

[language-server.nextflow-language-server]
command = "nextflow-language-server"

[language-server.nextflow-language-server.config.nextflow]
debug = true

[language-server.nextflow-language-server.config.nextflow.files]
exclude = [".git", ".nf-test", "work"]

[language-server.nextflow-language-server.config.nextflow.formatting]
harshilAlignment = true

This is my starter for ten, surely could be improved.

image

@nrminor
Copy link

nrminor commented Dec 3, 2024

Thanks for sharing this @tesujimath. Would you have any advice on getting syntax highlighting out of this setup? Previously, to work on Nextflow in helix, I was just using Groovy syntax highlighting:

[[language]]
name = "groovy"
file-types = ["groovy", "nf", "config"]
indent = { tab-width = 4, unit = "    " }

This of course no longer works with the Nextflow LSP, but perhaps there's a way to use the Nextflow LS with Groovy syntax highlighting? Fwiw, using the groovy tree-sitter grammar for nextflow did not enable this for me.

Syntax highlighting notwithstanding, though, the language server with your configuration works nicely for me as well!

@tesujimath
Copy link

@nrminor I haven't got syntax highlighting working yet, not had much time to look further at that. Would love to see a config with that. Glad to hear it's basically working for you.

(I tweaked my config for more known file types, updated above.)

@ewels ewels pinned this issue Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants