Skip to content

Commit

Permalink
feat!: remove the need for custom otter.nvim keybindings (#135)
Browse files Browse the repository at this point in the history
* wip

* adding keybindings is no longer necessary
  • Loading branch information
jmbuhr committed Jun 29, 2024
1 parent ea55d21 commit 1665721
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
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

0 comments on commit 1665721

Please sign in to comment.