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

add menu entries and/or commands to toggle plugins #345

Open
teto opened this issue Feb 19, 2024 · 1 comment
Open

add menu entries and/or commands to toggle plugins #345

teto opened this issue Feb 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@teto
Copy link

teto commented Feb 19, 2024

Feature description

Kind of an openended issue.
My initial issue is that I contribute to several haskell packages, and haskell plugins like stan or hlint are noisy in the diagnostics.
To work around this:

  1. One way to fix this is probably to ignore DEBUG/INFO diagnostics as a general diagnostic nvim functions. can be annoying if you want to keep hlint but not stan
  2. add a hls.json with the correct config in every project. Can be annoying if you can't commit it.
  3. change the config dynamically. This is the usecase I prefer, toggling on/off plugins at runtime .

Here is what I've tried:

M.toggle_stan = function ()
  local settings = M.generate_settings()

  settings.hls.default_settings.haskell.plugin.stan.globalOn = not settings.hls.default_settings.haskell.plugin.stan.globalOn
  return settings
end

M.restart_hls = function ()
 local new_settings = M.toggle_stan()
 vim.g.settings = new_settings
 vim.cmd [[ HlsRestart ]]
end

Seems to work. Looking at the HLS doc, it looks like it could be generalized, haskell-tools could parse the available plugins via --list-plugins and expose a :HlsTools plugin toggle/enable/disable <plugin>.

Unrelated/more of a general problem but I believe that a good way to expose commands could be to have a function that registers menu commands. For my own purpose I have created a local context menu where I add commands but maybe haskell-tools could have a

function register_menu_entries command (prefix)
   vim.cmd[[menu ]]..prefix..[[.Restart\ HLS  <cmd>HlsRestart<cr>]]
   ...
end
@teto teto added the enhancement New feature or request label Feb 19, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Feb 19, 2024

This sounds like a good idea!
Not sure I fully understand the "registering menu commands" thing though.

I've been planning to rework the commands, so that it's less polluting and more similar to how I implemented it with rustaceanvim: One :Hls command (for haskell-language-server) and :Ht (for non-hls tools) with subcommands and completions, e.g. :Hls [re]start, :Hls stop, :Hls plugin toggle, and :Ht repl [...], etc (see #297)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants