Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb79a7a8

Browse files
committed
chore(highlight): localize vim lua calls
1 parent1a7c6ad commitb79a7a8

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

‎lua/context/highlight.lua‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
localM= {}
2+
localvim=vim
3+
localapi=vim.api
4+
localinspect_pos=vim.inspect_pos
5+
localcontext_update=vim.fn["context#update"]
26

37
functionM:fill_hl_cache(row,col)
48
ifself.eol_col[row]==nilthen
5-
localline=vim.api.nvim_buf_get_lines(self.buf,row-1,row,false)[1]
9+
localline=api.nvim_buf_get_lines(self.buf,row-1,row,false)[1]
610
self.eol_col[row]=lineand#lineor0
711
end
812

@@ -12,15 +16,15 @@ function M:fill_hl_cache(row, col)
1216
end
1317

1418
-- needs nvim >0.9.0
15-
localpos=vim.inspect_pos(self.buf,row-1,col, {extmarks=false })
19+
localpos=inspect_pos(self.buf,row-1,col, {extmarks=false })
1620

1721
-- will fallback to treesitter if hl_group is empty
1822
if#pos.semantic_tokens>0then
1923
localhl_group=nil
2024
for_,tokeninipairs(pos.semantic_tokens)do
2125
-- TODO using nvim_get_hl() didn't work
2226
-- returns { [true] = 6 } if hl_group is empty
23-
ifvim.api.nvim_get_hl_by_name(token.opts.hl_group,true)[true]~=6then
27+
ifapi.nvim_get_hl_by_name(token.opts.hl_group,true)[true]~=6then
2428
hl_group=token.opts.hl_group
2529
end
2630
end
@@ -69,14 +73,14 @@ function M:get_highlight(row, col)
6973
self.scheduled=self.scheduled+1
7074
vim.schedule(function()
7175
self.scheduled=self.scheduled-1
72-
ifself.cached[row]==nilthen
76+
ifself.cached[row]==nilornotapi.nvim_buf_is_valid(self.buf)then
7377
return
7478
end
7579
self:fill_hl_cache(row,col)
7680
ifself.scheduled<1then
7781
-- last to finish triggers update
7882
self.scheduled=0
79-
vim.fn["context#update"]("OptionSet")-- need to use OptionSet to force update
83+
context_update("OptionSet")-- need to use OptionSet to force update
8084
end
8185
end)
8286

@@ -95,11 +99,11 @@ end
9599

96100
local_list= {}
97101
localfunctionnvim_hlgroup(winid,row,col)
98-
localbuf=vim.api.nvim_win_get_buf(winid)
102+
localbuf=api.nvim_win_get_buf(winid)
99103
localm=_list[buf]
100104
ifm==nilthen
101105
m=M.new(buf)
102-
vim.api.nvim_buf_attach(buf,false, {
106+
api.nvim_buf_attach(buf,false, {
103107
on_detach=function()
104108
_list[buf]=nil
105109
end,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp