diff options
| author | Fangrui Song <i@maskray.me> | 2025-01-01 21:25:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-02 13:25:52 +0800 |
| commit | 9194d0e863f9c8970021b23cf48685cfda289d07 (patch) | |
| tree | bdeba80e09b41c544003987ae1a8b4e925d57ed7 /lua | |
| parent | docs: update configs.md (diff) | |
| download | nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.tar nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.tar.gz nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.tar.bz2 nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.tar.lz nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.tar.xz nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.tar.zst nvim-lspconfig-9194d0e863f9c8970021b23cf48685cfda289d07.zip | |
feat(ccls): add CclsSwitchSourceHeader (#3535)
* feat(ccls): add CclsSwitchSourceHeader
ccls 0.20241108 has added support for the extension from clangd.
---------
Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/configs/ccls.lua | 27 |
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 |
