Comments (1)
Probably not worth the effort, one could simply fetch the symbol ranges and do something simple like that, for future reference to whoever comes around this issue of moving to next/prev usage in the buffer
local function lsp_moveto_usage(dir, pin)
usages = vim.tbl_map(function(r)
return {
start = { row = r.start.line, col = r.start.character },
finish = { row = r["end"].line, col = r["end"].character },
}
end, vim.fn.CocAction("symbolRanges") or {})
local cursor = vim.api.nvim_win_get_cursor(0)
local row = cursor[1] - 1; local col = cursor[2]
local oldignore = vim.o.eventignore
vim.o.eventignore = "CursorMoved"
usages = usages.result -- usages
for idx, pos in ipairs(usages) do
local new_position = nil
if dir > 0 and pin == 1 then
new_position = usages[#usages]
elseif dir < 0 and pin == 1 then
new_position = usages[1]
elseif row >= pos.start.row and row <= pos.finish.row and col >= pos.start.col and col <= pos.finish.col then
if dir < 0 and idx == 1 then
new_position = usages[#usages]
elseif dir > 0 and idx == #usages then
new_position = usages[1]
else
new_position = usages[idx + dir]
end
end
if type(new_position) == "table" then
vim.cmd.normal({ args = { "m'" } }) -- remember pos into the jumplist
local new_cursor = { new_position.start.row, new_position.start.col }
vim.api.nvim_win_set_cursor(0, { new_cursor[1] + 1, new_cursor[2] })
vim.cmd.normal({ args = { "m'" } }) -- remember pos into the jumplist
break
end
end
vim.schedule(function()
-- optionally highight also
vim.o.eventignore = oldignore
end)
end
from coc.nvim.
Related Issues (20)
- coc-rename - moves the cursor to the start of the first line HOT 9
- Hola Mundo
- 同时打开多个lsp时,会让rust-analyzer中断 HOT 5
- Error when installing on termux (Android) HOT 1
- 有什么配置可以让光标快速从括号里移动到右括号后吗?
- Coc API
- Is modifying current workspace available? HOT 3
- How to select an item HOT 5
- using singularity environment for R languageserver
- Extend CocDiagnostics or fillDiagnostics to work with CocList HOT 6
- Coc not updating workspace configuration
- Coc not updating user workspace folder config on demand HOT 3
- Some CoC extension features doesn't work when there's a space in the home directory on Windows HOT 1
- Keybindings when renaming
- 请问能够默认包含头文件和 自定义宏 进行检测, 不需要通过 #include 包含这个头文件
- Unable to correctly select the first parameter of the function HOT 4
- Is it able to open multiple list window. HOT 1
- List not work after some operation HOT 5
- client coc abnormal exit with: 4 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coc.nvim.