Skip to content

Commit

Permalink
Fix ddc#syntax#get() to work in insert mode
Browse files Browse the repository at this point in the history
  • Loading branch information
uga-rosa committed Dec 26, 2023
1 parent 9572f51 commit 27ccb0e
Showing 1 changed file with 9 additions and 3 deletions.
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] > 0
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

0 comments on commit 27ccb0e

Please sign in to comment.