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

Remove the need for nvim/nvim-lspconfig #37

Merged
merged 13 commits into from
Dec 26, 2020

Conversation

ckipp01
Copy link
Member

@ckipp01 ckipp01 commented Dec 22, 2020

I still need to clean up a few things and pretty much replace all of the documentation/readme, but this is the approach that I'd like to take. To summarize, this pr will get rid of the need for a user to have nvim/lsp-config installed. They still can if they want to, but this should become the preferred way to use Metals with nvim lsp mainly because of all the extra functionality and Metals-specific lsp extensions it provides. The main idea is that instead of having a user add in a bunch of handlers on their own and also have to keep adding them in as we add them, is for them to simply have the following:

if has('nvim-0.5')
  augroup lsp
    au!
    au FileType scala lua require('metals').initialize_or_attach({})
  augroup end
endif

This will basically provide all of the functionality that nvim/nvim-lspconfig and this extension provided before, but with way less work to setup. However, this still remains very customizable. For example, my personal setup locally looks like this:

:lua << EOF
  metals_config = {}
  metals_config.handlers = {}
  metals_config.init_options = {}

  metals_config.on_attach = function()
    require'completion'.on_attach();
  end

  metals_config.init_options.statusBarProvider = 'on'

  metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
    vim.lsp.diagnostic.on_publish_diagnostics, {
      virtual_text = {
        prefix = '',
      }
    }
  )
EOF

if has('nvim-0.5')
  augroup lsp
    au!
    au FileType scala lua require('metals').initialize_or_attach(metals_config)
  augroup end
endif

This allows me to use the on_attatch() from nvim-completions, change the default show-message to on to be able to use metals/status, and also customize how my diagnostics look.

This plugin also will fully handle the installation of Metals for the user by providing a :MetalsInstall command to put Metals in a specific location and use it. I've tried to be quite descriptive with messages to help the user know what's going on.

I still have some further things to do, but this will at least give an idea of the direction I'm headed.

@landerlo feel free to take a peak at this and give me any feedback.

TODO

  • Update readme with new instructions (keep in short, and focus on the help docs instead)
  • Update the metals.txt with basically all the information a user would need
  • Add in a :MetalsInfo command to give some practical info, basically the output of metals --version which shows the version of metals and also the supported Scala Versions. This command can also be used to show where Metals is installed
  • Fix CI -- figure out if I just want to use lua-format instead of luacheck
  • Figure out what I should do with the set shortmess-=F. This needs to be set in order for the FileType autocmd to display print, which is needed for the helpful messages.

@ckipp01 ckipp01 marked this pull request as ready for review December 23, 2020 20:11
@ckipp01
Copy link
Member Author

ckipp01 commented Dec 23, 2020

For anyone that stumbles onto this, you can find a short migration guide for these changes here: #17 (comment)

@ckipp01 ckipp01 merged commit f6aecb2 into scalameta:master Dec 26, 2020
@ckipp01 ckipp01 deleted the getRidOfLspConfig branch December 26, 2020 11:22
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

Successfully merging this pull request may close these issues.

1 participant