From d5748108b5f9e08c154a097bd7dd212f523368ea Mon Sep 17 00:00:00 2001 From: Jannik Buhr Date: Tue, 25 Jun 2024 16:36:40 +0200 Subject: [PATCH 1/2] wip --- ftplugin/quarto.lua | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/ftplugin/quarto.lua b/ftplugin/quarto.lua index 018e0ee..fe5d148 100644 --- a/ftplugin/quarto.lua +++ b/ftplugin/quarto.lua @@ -22,22 +22,27 @@ local function set_keymaps() set(config.keymap.format, ":lua require'otter'.ask_format()") end +local otterconfig = require('otter.config').cfg + 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 - -- - vim.api.nvim_create_autocmd('LspAttach', { - buffer = vim.api.nvim_get_current_buf(), - group = vim.api.nvim_create_augroup('QuartoKeymapSetup', {}), - callback = set_keymaps, - }) + -- only manually set keyjaks if not already done by otter + if not otterconfig.lsp.hijack then + 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 + -- + vim.api.nvim_create_autocmd('LspAttach', { + buffer = vim.api.nvim_get_current_buf(), + group = vim.api.nvim_create_augroup('QuartoKeymapSetup', {}), + callback = set_keymaps, + }) + end end From bc1d6540b21ff2964ab2ac785acf6858348947d0 Mon Sep 17 00:00:00 2001 From: Jannik Buhr Date: Fri, 28 Jun 2024 17:45:42 +0200 Subject: [PATCH 2/2] adding keybindings is no longer necessary --- ftplugin/quarto.lua | 40 ---------------------------------------- lua/quarto/config.lua | 9 --------- 2 files changed, 49 deletions(-) diff --git a/ftplugin/quarto.lua b/ftplugin/quarto.lua index fe5d148..9241a81 100644 --- a/ftplugin/quarto.lua +++ b/ftplugin/quarto.lua @@ -3,46 +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()") - set(config.keymap.type_definition, ":lua require'otter'.ask_type_definition()") - set(config.keymap.hover, ":lua require'otter'.ask_hover()") - set(config.keymap.rename, ":lua require'otter'.ask_rename()") - set(config.keymap.references, ":lua require'otter'.ask_references()") - set(config.keymap.document_symbols, ":lua require'otter'.ask_document_symbols()") - set(config.keymap.format, ":lua require'otter'.ask_format()") -end - -local otterconfig = require('otter.config').cfg - if config.lspFeatures.enabled then quarto.activate() - -- only manually set keyjaks if not already done by otter - if not otterconfig.lsp.hijack then - 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 - -- - vim.api.nvim_create_autocmd('LspAttach', { - buffer = vim.api.nvim_get_current_buf(), - group = vim.api.nvim_create_augroup('QuartoKeymapSetup', {}), - callback = set_keymaps, - }) - end end diff --git a/lua/quarto/config.lua b/lua/quarto/config.lua index 29a12ed..ece984c 100644 --- a/lua/quarto/config.lua +++ b/lua/quarto/config.lua @@ -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 = 'lR', - format = 'lf', - references = 'gr', - document_symbols = 'gS', - }, } -- use defaultConfig if not setup