Skip to content

Commit b31c2ba

Browse files
author
neo451
committed
feat: when using native completion, set auto trigger
1 parent e469f32 commit b31c2ba

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

lua/obsidian/lsp/handlers/completion.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ local CmpType = {
99
ref = 1,
1010
tag = 2,
1111
-- heading = 3,
12+
-- heading_all = 4,
13+
-- block = 5,
14+
-- block_all = 6,
1215
}
1316

1417
local RefPatterns = {
1518
[CmpType.ref] = "[[",
1619
[CmpType.tag] = "#",
17-
-- [CmpType.heading] = "[[## ",
20+
-- [CmpType.heading] = "[[# ",
21+
-- [CmpType.heading_all] = "[[## ",
22+
-- [CmpType.block] = "[[^ ",
23+
-- [CmpType.block_all] = "[[^^ ",
1824
}
1925

2026
---Collect matching anchor links.

lua/obsidian/lsp/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ lsp.start = function(buf)
3434
log.err("[obsidian-ls]: failed to start: " .. client_id)
3535
end
3636

37+
local has_blink = pcall(require, "blink.cmp")
38+
local has_cmp = pcall(require, "cmp")
39+
40+
if not (has_blink or has_cmp) and client_id then
41+
vim.lsp.completion.enable(true, client_id, buf, { autotrigger = true })
42+
vim.bo[buf].omnifunc = "v:lua.vim.lsp.omnifunc"
43+
vim.bo[buf].completeopt = "menu,menuone,noselect"
44+
vim.bo[buf].iskeyword = "@,48-57,192-255" -- HACK: so that completion for note names with `-` in it works in native completion
45+
end
46+
3747
return client_id
3848
end
3949

minimal.lua

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,17 @@ local plugins = {
4545
-- }
4646
-- end,
4747
-- },
48-
{
49-
"saghen/blink.cmp",
50-
opts = {
51-
fuzzy = { implementation = "lua" }, -- no need to build binary
52-
},
53-
},
48+
-- {
49+
-- "saghen/blink.cmp",
50+
-- build = "cargo build --release",
51+
-- opts = {
52+
-- cmdline = { enabled = false },
53+
-- completion = {
54+
-- documentation = { auto_show = true },
55+
-- },
56+
-- -- fuzzy = { implementation = "lua" }, -- no need to build binary
57+
-- },
58+
-- },
5459
}
5560

5661
require("lazy.minit").repro { spec = plugins }

0 commit comments

Comments
 (0)