1
- -- Needed for notebooks
2
- require (" quarto" ).activate ()
1
+ vim .b .slime_cell_delimiter = " ```"
2
+
3
+ local config = require (" quarto.config" ).config
4
+ local quarto = require (" quarto" )
5
+
6
+ local function set_keymaps ()
7
+ local b = vim .api .nvim_get_current_buf ()
8
+ local function set (lhs , rhs )
9
+ vim .api .nvim_buf_set_keymap (b , " n" , lhs , rhs , { silent = true , noremap = true })
10
+ end
11
+ set (config .keymap .definition , " :lua require'otter'.ask_definition()<cr>" )
12
+ set (config .keymap .type_definition , " :lua require'otter'.ask_type_definition()<cr>" )
13
+ set (config .keymap .hover , " :lua require'otter'.ask_hover()<cr>" )
14
+ set (config .keymap .rename , " :lua require'otter'.ask_rename()<cr>" )
15
+ set (config .keymap .references , " :lua require'otter'.ask_references()<cr>" )
16
+ set (config .keymap .document_symbols , " :lua require'otter'.ask_document_symbols()<cr>" )
17
+ set (config .keymap .format , " :lua require'otter'.ask_format()<cr>" )
18
+ end
19
+
20
+ if config .lspFeatures .enabled then
21
+ quarto .activate ()
22
+ set_keymaps ()
23
+ -- set the keymap again if a language server attaches
24
+ -- directly to this buffer
25
+ -- because it probably overwrites these in `LspAttach`
26
+ -- TODO: make this more robust
27
+ -- This currently only works if 'LspAttach' is used
28
+ -- directly, e.g. in LazyVim
29
+ -- It does no work if the `on_attach` callback
30
+ -- is used in the lspconfig setup
31
+ -- because this gets executed after the `LspAttach` autocommand
32
+ -- <https://github.com/neovim/neovim/blob/d0d132fbd055834cbecb3d4e3a123a6ea8f099ec/runtime/lua/vim/lsp.lua#L1702-L1711>
33
+ vim .api .nvim_create_autocmd (" LspAttach" , {
34
+ buffer = vim .api .nvim_get_current_buf (),
35
+ group = vim .api .nvim_create_augroup (" QuartoKeymapSetup" , {}),
36
+ callback = set_keymaps ,
37
+ })
38
+ end
0 commit comments