Comments (5)
are you looking for mapnew()
?
from vim.
are you looking for
mapnew()
?
it works, thanks.
btw, the function I need are as follows
def Hiset(group: string, fg: list<string>, bg: list<string>, ...strlist: list<string>)
var attr: dict<bool>
var val: dict<bool> = strlist->empty() ? {'NONE': v:true} :
strlist[0]->split(',')->map((_, v) => {
attr[v] = v:true
return attr
})[0]
hlset([{
name: group,
guifg: fg[0], guibg: bg[0], gui: val,
ctermfg: fg[1], ctermbg: bg[1], cterm: val,
}])
enddef
Hiset('ErrorMsg', palette.red, palette.none, 'bold,underline')
from vim.
BTW: now you can also use the foreach()
expression.
from vim.
BTW: now you can also use the
foreach()
expression.
thanks, I'm just reporting the issue I found.
I want to implement a function that return a dict variable using vim9 lambda, foreach
expression does not apply to my needs
from vim.
BTW: now you can also use the
foreach()
expression.
Already used
vim9script noclear
highlight default JumpFocus guifg=#958c6a
highlight default JumpMain guifg=#f2119c gui=bold cterm=bold
const limit = 200
var table: list<dict<any>>
def Init()
var name: string
var str: list<string> = 'fjdklshgaewiomc'->split('\zs')
var len: number = str->len()
for idx in range(limit)
table->add({'name': str[idx / len] .. str[idx % len]})
name = table[idx]['name']
table[idx][name] = popup_create(name, {hidden: true, wrap: false, tabpage: -1, highlight: "JumpMain"})
endfor
enddef
def Show(lnum: number, end: number)
var len: number
var ch: string
var id: number
var screen_pos: dict<any>
var input: string
id = matchaddpos("JumpFocus", range(lnum, end))
defer matchdelete(id)
redraw
ch = nr2char(getchar())
len = foreach(matchbufline(bufnr(), '\<\k\+\>', lnum, end)
->filter((_, v) => v.text =~? ch),
"table[v:key]['pos'] = v:val")->len()
if len == 0
return
elseif len >= limit
len = limit
endif
for idx in range(len)
screen_pos = screenpos(winnr(), table[idx]['pos']['lnum'], table[idx]['pos']['byteidx'] + 1)
popup_move(table[idx][table[idx].name], {line: screen_pos.row, col: screen_pos.curscol})
popup_show(table[idx][table[idx].name])
endfor
redraw
for _ in range(2)
input ..= nr2char(getchar())
if input !~# '\l'
break
endif
endfor
for idx in range(len)
if table[idx]->has_key(input)
cursor(table[idx]['pos']['lnum'], table[idx]['pos']['byteidx'] + 1)
endif
popup_hide(table[idx][table[idx].name])
endfor
enddef
export def Jump()
var conceal: number
if table->empty()
Init()
endif
conceal = &conceallevel
&conceallevel = 0
Show(line('w0'), line('w$'))
&conceallevel = conceal
enddef
from vim.
Related Issues (20)
- Remove/modify filetype indent for asm files HOT 4
- Add commentstring for dart filetypes HOT 2
- select breaks syntax highlighting in bash HOT 7
- [vim9]Memory Leak when assigning a lambda function decorated in a HigherOrder function to a variable
- Escaped `,` and `:` in patterns in `b:match_words` is not correctly unescaped
- listchars: trailmultispace to easily identify the number of trailing spaces HOT 6
- Msys vim's executable() can't find programs despite them being add in the PATH HOT 10
- Minor syntax highlighting issue with swayconfig files HOT 3
- no help for comment.txt for the newly introduced comment.vim plugin HOT 3
- search() vs ignorecase vs smartcase HOT 4
- A correction to the docs HOT 2
- New compiler warnings in 9.1.444 HOT 1
- HighlightedYank feature HOT 10
- No indentation of HTML tags in PHP files HOT 2
- Update defaults.vim HOT 9
- Update syntax/markdown.vim: Don't allow space between link text and URL HOT 1
- [''] and [{}] behave differently as repeat function parameter HOT 2
- Vim syntax bug HOT 4
- how to use Vim
- :echo works incorrectly in gVim HOT 1
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 vim.