feat: move to utils
This commit is contained in:
parent
e059a4fa42
commit
287f81729f
2 changed files with 9 additions and 10 deletions
|
@ -1,16 +1,7 @@
|
|||
local utils = require('cosmic.utils')
|
||||
local lsp_utils = require('cosmic.utils.lsp')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local M = {}
|
||||
|
||||
local function toggle_inlay_hints(bufnr)
|
||||
local enabled = user_config.lsp.inlay_hint
|
||||
return function()
|
||||
enabled = not enabled
|
||||
vim.lsp.inlay_hint(bufnr, enabled)
|
||||
end
|
||||
end
|
||||
|
||||
-- Mappings.
|
||||
function M.init(client, bufnr)
|
||||
local buf_map = utils.create_buf_map(bufnr, {
|
||||
|
@ -44,7 +35,7 @@ function M.init(client, bufnr)
|
|||
|
||||
-- inlay hints
|
||||
if client.supports_method('textDocument/inlayHint') then
|
||||
buf_map('n', '<leader>lh', toggle_inlay_hints(bufnr), { desc = 'Toggle inlay hints for buffer' })
|
||||
buf_map('n', '<leader>lh', lsp_utils.toggle_inlay_hints(bufnr), { desc = 'Toggle inlay hints for buffer' })
|
||||
end
|
||||
|
||||
-- code actions
|
||||
|
|
|
@ -69,4 +69,12 @@ function M.get_lsp_status_str()
|
|||
return client_str
|
||||
end
|
||||
|
||||
function M.toggle_inlay_hints(bufnr)
|
||||
local enabled = user_config.lsp.inlay_hint
|
||||
return function()
|
||||
enabled = not enabled
|
||||
vim.lsp.inlay_hint(bufnr, enabled)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Reference in a new issue