Skip to content

Commit ed038fe

Browse files
committed
fix: start method takes a buf
1 parent e0944a5 commit ed038fe

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

lua/obsidian/client.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ end
21282128
--- Start the lsp client
21292129
---
21302130
---@return integer
2131-
Client.lsp_start = function(self)
2131+
Client.lsp_start = function(self, buf)
21322132
local handlers = require "obsidian.lsp.handlers"
21332133
local has_blink, blink = pcall(require, "blink.cmp")
21342134
local has_cmp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
@@ -2141,6 +2141,7 @@ Client.lsp_start = function(self)
21412141
else
21422142
capabilities = vim.lsp.protocol.make_client_capabilities()
21432143
end
2144+
21442145
local client_id = vim.lsp.start {
21452146
name = "obsidian-ls",
21462147
capabilities = capabilities,
@@ -2150,7 +2151,6 @@ Client.lsp_start = function(self)
21502151
handlers[method](self, params, handler, _)
21512152
end,
21522153
notify = function(method, params, handler, _)
2153-
print(method)
21542154
handlers[method](self, params, handler, _)
21552155
end,
21562156
is_closing = function() end,
@@ -2162,6 +2162,13 @@ Client.lsp_start = function(self)
21622162
}
21632163
assert(client_id, "failed to start obsidian_ls")
21642164

2165+
if not (has_blink or has_cmp) then
2166+
vim.lsp.completion.enable(true, client_id, buf, { autotrigger = true })
2167+
vim.bo[buf].omnifunc = "v:lua.vim.lsp.omnifunc"
2168+
vim.bo[buf].completeopt = "menu,menuone,noselect"
2169+
vim.bo[buf].iskeyword = "@,48-57,192-255" -- HACK: so that completion for note names with `-` in it works in native completion
2170+
end
2171+
21652172
return client_id
21662173
end
21672174

lua/obsidian/init.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ obsidian.setup = function(opts)
144144
vim.keymap.set("n", mapping_keys, mapping_config.action, mapping_config.opts)
145145
end
146146

147-
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
148-
vim.bo[ev.buf].completeopt = "menu,menuone,noselect"
149-
vim.bo[ev.buf].iskeyword = "@,48-57,192-255" -- HACK: so that completion for note names with `-` in it works in native completion
150-
151-
local client_id = client:lsp_start()
147+
local client_id = client:lsp_start(ev.buf)
152148

153149
vim.keymap.set("n", "<leader>ii", function()
154150
local lsp_client = assert(vim.lsp.get_client_by_id(client_id))

0 commit comments

Comments
 (0)