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

Fix ddc#syntax#get() to work in insert mode #144

Merged
merged 1 commit into from
Dec 26, 2023
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
12 changes: 9 additions & 3 deletions autoload/ddc/syntax.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ function ddc#syntax#in(checks) abort
endfunction

function ddc#syntax#get() abort
const curpos = getcurpos()[1:2]
return &l:syntax !=# '' ? s:get_syn_names([curpos[0], curpos[1] - 1]) :
\ has('nvim') ? v:lua.vim.treesitter.get_captures_at_cursor(0) : []
let curpos = getcurpos()[1:2]
if mode() ==# 'i' && curpos[1] > 1
let curpos[1] -= 1
endif
return &l:syntax !=# '' ? s:get_syn_names([curpos[0], curpos[1] - 1])
\ : has('nvim') ?
\ v:lua.vim.treesitter.get_captures_at_pos(0,
\ curpos[0] - 1, curpos[1] - 1)->map('v:val.capture')
\ : []
endfunction

function ddc#syntax#lang() abort
Expand Down
Loading