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

feat!: remove the need for custom otter.nvim keybindings #135

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 0 additions & 35 deletions ftplugin/quarto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,6 @@ vim.b.slime_cell_delimiter = '```'
local config = require('quarto.config').config
local quarto = require 'quarto'

local function set_keymaps()
if not config.keymap then
return
end
local b = vim.api.nvim_get_current_buf()
local function set(lhs, rhs)
if lhs then
vim.api.nvim_buf_set_keymap(b, 'n', lhs, rhs, { silent = true, noremap = true })
end
end
set(config.keymap.definition, ":lua require'otter'.ask_definition()<cr>")
set(config.keymap.type_definition, ":lua require'otter'.ask_type_definition()<cr>")
set(config.keymap.hover, ":lua require'otter'.ask_hover()<cr>")
set(config.keymap.rename, ":lua require'otter'.ask_rename()<cr>")
set(config.keymap.references, ":lua require'otter'.ask_references()<cr>")
set(config.keymap.document_symbols, ":lua require'otter'.ask_document_symbols()<cr>")
set(config.keymap.format, ":lua require'otter'.ask_format()<cr>")
end

if config.lspFeatures.enabled then
quarto.activate()
set_keymaps()
-- set the keymap again if a language server attaches
-- directly to this buffer
-- because it probably overwrites these in `LspAttach`
-- TODO: make this more robust
-- This currently only works if 'LspAttach' is used
-- directly, e.g. in LazyVim
-- It does no work if the `on_attach` callback
-- is used in the lspconfig setup
-- because this gets executed after the `LspAttach` autocommand
-- <https://github.com/neovim/neovim/blob/d0d132fbd055834cbecb3d4e3a123a6ea8f099ec/runtime/lua/vim/lsp.lua#L1702-L1711>
vim.api.nvim_create_autocmd('LspAttach', {
buffer = vim.api.nvim_get_current_buf(),
group = vim.api.nvim_create_augroup('QuartoKeymapSetup', {}),
callback = set_keymaps,
})
end
9 changes: 0 additions & 9 deletions lua/quarto/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ M.defaultConfig = {
-- Takes precedence over `default_method`
never_run = { 'yaml' }, -- filetypes which are never sent to a code runner
},
keymap = {
hover = 'K',
definition = 'gd',
type_definition = 'gD',
rename = '<leader>lR',
format = '<leader>lf',
references = 'gr',
document_symbols = 'gS',
},
}

-- use defaultConfig if not setup
Expand Down
Loading