aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/configs/ccls.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/lspconfig/configs/ccls.lua b/lua/lspconfig/configs/ccls.lua
index 43bc8b12..1f0e937d 100644
--- a/lua/lspconfig/configs/ccls.lua
+++ b/lua/lspconfig/configs/ccls.lua
@@ -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' },
@@ -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