lazy clangd

This commit is contained in:
dlond 2025-05-30 20:19:13 +12:00
parent 22b264311a
commit f6d5957079
1 changed files with 5 additions and 4 deletions

View File

@ -137,21 +137,22 @@ end
return {
'neovim/nvim-lspconfig',
ft = M.clang_filetypes,
config = function()
vim.api.nvim_create_autocmd('BufReadPost', {
group = vim.api.nvim_create_augroup('clangd-once', { clear = true }),
pattern = '*',
callback = function(args)
local ft = vim.bo[args.buf].filetype
if vim.tbl_contains(require('custom.plugins.lsp.clangd').clang_filetypes, ft) then
local M = require 'custom.plugins.lsp.clangd'
if vim.tbl_contains(M.clang_filetypes, ft) then
local dir = M.find_compile_commands()
M.start_clangd(dir)
vim.api.nvim_clear_autocmds { group = 'clangd-once' }
end
end,
})
vim.keymap.set('n', '<leader>lc', M.pick_commands_dir, { desc = '[L]ocate [c]ompile_commands.json for clangd' })
vim.keymap.set('n', '<leader>lc', M.pick_commands_dir, {
desc = '[L]ocate [c]ompile_commands.json for clangd',
})
end,
}