-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathotter.lua
33 lines (30 loc) · 974 Bytes
/
otter.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local ot = require('otter')
local utils = require('utils')
-- Wrap `ot.activate()` in `pcall()` to suppress error when opening git diff
-- for markdown files: 'Vim(append):Error executing lua callback: Vim:E95:
-- Buffer with this name already exists'
local _ot_activate = ot.activate
function ot.activate(...)
pcall(_ot_activate, ...)
end
ot.setup({
verbose = { no_code_found = false },
buffers = { set_filetype = true },
lsp = {
root_dir = function()
return vim.fs.root(0, utils.fs.root_patterns) or vim.fn.getcwd(0)
end,
},
})
vim.api.nvim_create_autocmd('FileType', {
desc = 'Activate otter for filetypes with injections.',
group = vim.api.nvim_create_augroup('OtterActivate', {}),
pattern = { 'markdown', 'norg', 'org' },
callback = function(info)
local buf = info.buf
if vim.bo[buf].ma and utils.ts.is_active(buf) then
-- Enable completion only, disable diagnostics
ot.activate(nil, nil, false)
end
end,
})