-
-
Save semanticart/7f2f838b41521a6d20ca50eda6458969 to your computer and use it in GitHub Desktop.
An example code action for null-ls.nvim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local frozen_string_actions = { | |
method = null_ls.methods.CODE_ACTION, | |
filetypes = {"ruby"}, | |
generator = { | |
fn = function(context) | |
frozen_string_literal_comment = "# frozen_string_literal: true" | |
first_line = context.content[1] | |
if first_line ~= frozen_string_literal_comment then | |
return { | |
{ | |
title = "🥶Add frozen string literal comment", | |
action = function() | |
lines = { | |
frozen_string_literal_comment, "", first_line | |
} | |
vim.api.nvim_buf_set_lines(context.bufnr, 0, 1, | |
false, lines) | |
end | |
} | |
} | |
end | |
end | |
} | |
} | |
null_ls.register(frozen_string_actions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment