Skip to content

Commit

Permalink
feat(ccls): add CclsSwitchSourceHeader (#3535)
Browse files Browse the repository at this point in the history
* feat(ccls): add CclsSwitchSourceHeader

ccls 0.20241108 has added support for the extension from clangd.


---------

Co-authored-by: glepnir <[email protected]>
  • Loading branch information
MaskRay and glepnir authored Jan 2, 2025
1 parent 8b15a1a commit 9194d0e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lua/lspconfig/configs/ccls.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
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')
if not client then
vim.notify('method textdocument/switchsourceheader is not supported by any servers active on the current buffer')
end
local params = vim.lsp.util.make_text_document_params(bufnr)
client.request('textdocument/switchsourceheader', params, function(err, result)
if err then
error(tostring(err))
end
if not result then
vim.notify('corresponding file cannot be determined')
return
end
vim.cmd.edit(vim.uri_to_fname(result))
end, bufnr)
end

return {
default_config = {
cmd = { 'ccls' },
Expand All @@ -12,6 +31,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 9194d0e

Please sign in to comment.