Skip to content

Custom command to run test in terminal #24

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Autocommand to refresh codelens when attaching to Ruby buffer
  • Loading branch information
adam12 committed Apr 24, 2025
commit 0c9f907dc0e23ea9b1f1f7e2745c6c0d55ac67de
10 changes: 10 additions & 0 deletions lua/ruby-lsp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ ruby_lsp.setup = function(config)

local server_started = false

-- TODO: Do I like this here?
vim.api.nvim_create_autocmd('LspAttach', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example given in the nvim docs triggers a refresh on BufEnter,CursorHold,InsertLeave. I'm not sure how much of a performance hit this would be. If you go this route, it would make sense to create buffer-local autocmds, or use a pattern filter.

Copy link
Contributor

@christopher-b christopher-b Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somthing like

vim.api.nvim_create_autocmd({ 'BufEnter', 'CursorHold', 'InsertLeave' }, {
  pattern = { '*.rb' },
  callback = function(args)
    vim.lsp.codelens.refresh({ bufnr = args.buf })
  end,
})

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely more appropriate. Let's go with it!

callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client and client.name == 'ruby_lsp' then
vim.lsp.codelens.refresh({bufnr = args.buf})
end
end
}) -- TODO: Should we group it? and add description?

-- Autocommand to only install ruby-lsp server when opening a Ruby file
vim.api.nvim_create_autocmd('FileType', {
pattern = {'ruby', 'eruby'},
Expand Down