Skip to content

Commit

Permalink
feat(ccls): add CclsSwitchSourceHeader
Browse files Browse the repository at this point in the history
ccls 0.20241108 has added support for the extension from clangd.
  • Loading branch information
MaskRay committed Jan 2, 2025
1 parent ae8a01b commit 456cc23
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lua/lspconfig/configs/ccls.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
local util = require 'lspconfig.util'

local function switch_source_header(bufnr)
bufnr = util.validate_bufnr(bufnr)
local client = util.get_active_client_by_name(bufnr, 'ccls')
local params = { uri = vim.uri_from_bufnr(bufnr) }
if client then
client.request('textDocument/switchSourceHeader', params, function(err, result)
if err then
error(tostring(err))
end
if not result then
print 'Corresponding file cannot be determined'
return
end
vim.api.nvim_command('edit ' .. vim.uri_to_fname(result))
end, bufnr)
else
print 'method textDocument/switchSourceHeader is not supported by any servers active on the current buffer'
end
end

return {
default_config = {
cmd = { 'ccls' },
Expand All @@ -12,6 +32,14 @@ return {
-- ccls does not support sending a null root directory
single_file_support = false,
},
commands = {
CclsSwitchSourceHeader = {
function()
switch_source_header(0)
end,
description = 'Switch between source/header',
},
},
docs = {
description = [[
https://github.com/MaskRay/ccls/wiki
Expand Down

0 comments on commit 456cc23

Please sign in to comment.