mirror of
https://github.com/MaskRay/ccls.git
synced 2025-10-14 03:52:32 +00:00
Updated nvim lspconfig (markdown)
parent
9f2230b7d9
commit
ab8c557fe7
@ -1,3 +1,5 @@
|
||||
# Install
|
||||
|
||||
Install [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) according to the instructions in its README.
|
||||
|
||||
<https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/ccls.lua> has a built-in rule for ccls.
|
||||
@ -13,3 +15,34 @@ lspconfig.ccls.setup {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# ccls extensions
|
||||
|
||||
To use ccls extensions, e.g., `$ccls/inheritance`, `$ccls/member`, etc., we need some hacks.
|
||||
|
||||
1. Copy `get_location` function from `nvim/runtime/lua/vim/lsp/buf.lua` to `~/.config/nvim/lua/get_location.lua`, and modify it to support custom parameters. An example can be found at [here](https://github.com/zsrkmyn/dotvim/blob/master/lua/get_location.lua), and you can directly use it.
|
||||
2. In `init.lua`, add kepmaps on attach, e.g.,
|
||||
```
|
||||
local get_location = require'get_location'
|
||||
require'lspconfig'.ccls.setup {
|
||||
-- ...
|
||||
on_attach = function(client, bufnr)
|
||||
local opts = { buffer = bufnr, remap = false }
|
||||
local lopts = { loclist = true }
|
||||
-- ...
|
||||
vim.keymap.set('n', 'gxb', function() get_location('$ccls/inheritance', {}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxB', function() get_location('$ccls/inheritance', {levels=3}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxd', function() get_location('$ccls/inheritance', {derived=true}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxD', function() get_location('$ccls/inheritance', {derived=true, levels=3}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxc', function() get_location('$ccls/call', {}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxC', function() get_location('$ccls/call', {callee=true}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxs', function() get_location('$ccls/member', {kind=2}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxf', function() get_location('$ccls/member', {kind=3}, lopts) end, opts)
|
||||
vim.keymap.set('n', 'gxm', function() get_location('$ccls/member', {}, lopts) end, opts)
|
||||
vim.keymap.set('n', '<C-j>', function() get_location('$ccls/navigate', {direction='D'}, lopts) end, opts)
|
||||
vim.keymap.set('n', '<C-k>', function() get_location('$ccls/navigate', {direction='U'}, lopts) end, opts)
|
||||
vim.keymap.set('n', '<C-h>', function() get_location('$ccls/navigate', {direction='L'}, lopts) end, opts)
|
||||
vim.keymap.set('n', '<C-l>', function() get_location('$ccls/navigate', {direction='R'}, lopts) end, opts)
|
||||
end,
|
||||
-- ...
|
||||
```
|
Loading…
Reference in New Issue
Block a user