Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ccls): add CclsSwitchSourceHeader #3535

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

glepnir marked this conversation as resolved.
Show resolved Hide resolved
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
Loading