more fixes
This commit is contained in:
parent
f7d3587953
commit
64f2e2dc27
|
@ -109,20 +109,24 @@ return {
|
||||||
|
|
||||||
reload_clangd = function(self)
|
reload_clangd = function(self)
|
||||||
local lspconfig = require 'lspconfig'
|
local lspconfig = require 'lspconfig'
|
||||||
local clients = vim.lsp.get_clients { name = 'clangd' }
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
|
local ft = vim.bo[buf].filetype
|
||||||
|
if vim.api.nvim_buf_get_name(buf) == '' or not vim.tbl_contains({ 'c', 'cpp', 'objc', 'objcpp' }, ft) then
|
||||||
|
vim.notify('Not reloading clangd: no file or wrong filetype', vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for _, client in ipairs(clients) do
|
for _, client in ipairs(vim.lsp.get_clients()) do
|
||||||
|
if client.name == 'clangd' then
|
||||||
client.stop()
|
client.stop()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
lspconfig.clangd.setup {
|
lspconfig.clangd.setup {
|
||||||
cmd = self:make_clangd_cmd(self:get_target()),
|
cmd = self:make_clangd_cmd(self:get_target()),
|
||||||
}
|
}
|
||||||
local bufname = vim.api.nvim_buf_get_name(0)
|
|
||||||
if bufname ~= '' then
|
|
||||||
vim.cmd 'edit'
|
vim.cmd 'edit'
|
||||||
end
|
|
||||||
end, 200)
|
end, 200)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue