spinks / vim-leader-guide Goto Github PK
View Code? Open in Web Editor NEWShow neovim mappings in popup
License: MIT License
Show neovim mappings in popup
License: MIT License
If I use vim.keymap.set and pass a lua function as rhs like this:
vim.keymap.set('n', '<Leader>cc', function()
return vim.v.count == 0 and '<Plug>(comment_toggle_current_linewise)' or '<Plug>(comment_toggle_linewise_count)'
end, { expr = true })
I get the following error on opening leader guide:
Error detected while processing function leaderGuide#start_by_prefix[12]..<SNR>17_start_parser:
line 11:
E716: Key not present in Dictionary: "lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'"
line 12: continue
line 13: endif
line 14: let mapd.display = s:format_displaystring(mapd.rhs)
line 14:
E716: Key not present in Dictionary: "rhs)"
E116: Invalid arguments for function s:format_displaystring
line 15: let mapd.lhs = substitute(mapd.lhs, key, "", "")
line 15:
E716: Key not present in Dictionary: "lhs, key, "", "")"
E116: Invalid arguments for function substitute
line 16: let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
line 16:
E716: Key not present in Dictionary: "lhs, "<Space>", " ", "g")"
E116: Invalid arguments for function substitute
line 17: let mapd.lhs = substitute(mapd.lhs, "<Tab>", "<C-I>", "g")
line 17:
E716: Key not present in Dictionary: "lhs, "<Tab>", "<C-I>", "g")"
E116: Invalid arguments for function substitute
line 18: let mapd.rhs = substitute(mapd.rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
line 18:
E716: Key not present in Dictionary: "rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")"
E116: Invalid arguments for function substitute
line 19: if mapd.lhs != '' && mapd.display !~# 'LeaderGuide.*'
line 19:
E716: Key not present in Dictionary: "lhs != '' && mapd.display !~# 'LeaderGuide.*'"
line 20: if (visual && match(mapd.mode, "[vx ]") >= 0) || (!visual && match(mapd.mode, "[vx]") == -1)
line 22: let mapd.lhs = s:string_to_keys(mapd.lhs)
line 23: call s:add_map_to_dict(mapd, 0, a:dict)
line 24: endif
line 25: endif
line 26: endfor
line 9: for line in lines
line 10: let mapd = maparg(split(line[3:])[0], line[0], 0, 1)
line 11: if mapd.lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'
line 11:
E716: Key not present in Dictionary: "lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'"
line 12: continue
line 13: endif
line 14: let mapd.display = s:format_displaystring(mapd.rhs)
line 14:
E716: Key not present in Dictionary: "rhs)"
E116: Invalid arguments for function s:format_displaystring
line 15: let mapd.lhs = substitute(mapd.lhs, key, "", "")
line 15:
E716: Key not present in Dictionary: "lhs, key, "", "")"
E116: Invalid arguments for function substitute
line 16: let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
line 16:
E716: Key not present in Dictionary: "lhs, "<Space>", " ", "g")"
E116: Invalid arguments for function substitute
line 17: let mapd.lhs = substitute(mapd.lhs, "<Tab>", "<C-I>", "g")
line 17:
E716: Key not present in Dictionary: "lhs, "<Tab>", "<C-I>", "g")"
E116: Invalid arguments for function substitute
line 18: let mapd.rhs = substitute(mapd.rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
line 18:
E716: Key not present in Dictionary: "rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")"
E116: Invalid arguments for function substitute
line 19: if mapd.lhs != '' && mapd.display !~# 'LeaderGuide.*'
line 19:
E716: Key not present in Dictionary: "lhs != '' && mapd.display !~# 'LeaderGuide.*'"
line 20: if (visual && match(mapd.mode, "[vx ]") >= 0) || (!visual && match(mapd.mode, "[vx]") == -1)
line 22: let mapd.lhs = s:string_to_keys(mapd.lhs)
line 23: call s:add_map_to_dict(mapd, 0, a:dict)
line 24: endif
line 25: endif
line 26: endfor
line 9: for line in lines
line 10: let mapd = maparg(split(line[3:])[0], line[0], 0, 1)
line 10:
E684: list index out of range: 0
E116: Invalid arguments for function maparg
line 11: if mapd.lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'
line 11:
E716: Key not present in Dictionary: "lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'"
line 12: continue
line 13: endif
line 14: let mapd.display = s:format_displaystring(mapd.rhs)
line 14:
E716: Key not present in Dictionary: "rhs)"
E116: Invalid arguments for function s:format_displaystring
line 15: let mapd.lhs = substitute(mapd.lhs, key, "", "")
line 15:
E716: Key not present in Dictionary: "lhs, key, "", "")"
E116: Invalid arguments for function substitute
line 16: let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
line 16:
E716: Key not present in Dictionary: "lhs, "<Space>", " ", "g")"
function leaderGuide#start_by_prefix[12]..<SNR>17_start_parser aborted
continuing in function leaderGuide#start_by_prefix
function leaderGuide#start_by_prefix aborted
Hello. I already tried with success the original vim-leader-guide with the classical init.vim and Plug.
Now I'm rewriting my configuration mostly in lua and use packer. And now the plugin doesn't work anymore. Typing the leader key doesn't seem to call the plugin. And if I try to start it with the command, it has no entry.
This is the minimal config that reproduce my issue:
-- init.lua
local install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.execute('!git clone https://github.com/wbthomason/packer.nvim ' .. install_path)
end
vim.g.mapleader = '\\<Space>'
vim.g.localleader = ','
vim.keymap.set(
{'n', 'v'},
'<Space>',
'<Nop>'
)
require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
use 'spinks/vim-leader-guide'
end)
vim.cmd('source ' .. vim.fn.stdpath('config') .. '/leader.vim')
" leader.vim
let g:lmap = {}
nnoremap <leader>? :Cheatsheet<CR>
let g:lmap['?'] = 'Cheatsheet'
call leaderGuide#register_prefix_descriptions('<Space>', 'g:lmap')
nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
map <leader>. <Plug>leaderguide-global
map <localleader>. <Plug>leaderguide-buffer
I probably did something stupid, but I can't figure it out.
Hi,
could you add a license please?
I've been using hecal3/vim-leader-guide
for a while, with a few grievances -- but generally grateful, and I was excited to see someone forked it.
I would love to help, but I have very little understanding of vim script. I still hope to help since I like the idea.
So I just switched to this repo and I was kind of hoping it would be as simple as switching the plugin, but the leader guide doesn't seem to show up.
I've been going over your readme with out getting much farther and thought I'd just ask what you think I may be missing.
Here is my leader.vim
config thats been working with hecal3
version.
I also use neovim, and maybe that might be a issue.
nnoremap <Space> <Nop>
let mapleader = "\<Space>"
call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
let g:lmap = {}
"----- Files
let g:ranger_map_keys = 0 " Ranger auto maps this to <leader>f
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:lmap.f = { 'name' : 'Files',
\ 'r' : ['Ranger', 'Find Files (Ranger)'],
\ 'F' : ['call fzf#run()', 'Find Files (FZF)'],
\ 'f' : ['MyGF', 'Find All Files (Custom GFiles)'],
\ 's' : ['w', 'Save File'],
\ 'S' : ['wa', 'Save All Files'],
\ 'x' : ['x', 'Save & Close'],
\ }
"----- Buffers
let g:lmap.b = { 'name' : 'Buffers',
\ 'b' : [':CtrlPBuffer', 'CtrlP Buffers'],
\ 'r' : ['e', 'Reload Buffer'],
\ 'd' : ['bd', 'Delete Buffer'],
\ 'D' : ['Bclose', 'Close All Buffers'],
\ 'n' : ['bn', 'Next Buffer'],
\ 'p' : ['bp', 'Previous Buffer'],
\ }
"----- Window
function! MaximizeToggle()
if exists("s:maximize_session")
exec "source " . s:maximize_session
call delete(s:maximize_session)
unlet s:maximize_session
let &hidden=s:maximize_hidden_save
unlet s:maximize_hidden_save
else
let s:maximize_hidden_save = &hidden
let s:maximize_session = tempname()
set hidden
exec "mksession! " . s:maximize_session
only
endif
endfunction
autocmd VimResized * :wincmd =
set splitbelow
set splitright
let g:lmap.w = { 'name' : '+ Windows',
\ 'd' : ['close', 'Close Window'],
\ 's' : ['split', 'Horizontal Split'],
\ 'v' : ['vsplit', 'Vertical Split'],
\ 'h' : ['wincmd h', 'Move Left'],
\ 'l' : ['wincmd l', 'Move Right'],
\ 'j' : ['wincmd j', 'Move Down'],
\ 'k' : ['wincmd k', 'Move Up'],
\ 't' : ['call MaximizeToggle()', 'Close Others'],
\ '=': ['wincmd =', 'Resize Equally'],
\ }
"----- Git
let g:lmap.g = { 'name' : 'Git',
\ 'a' : ['Gwrite', 'Git Add File'],
\ 'b' : ['Gblame', 'Git Blame'],
\ 'c' : ['Gcommit', 'Git Commit'],
\ 'd' : ['Gdiff', 'Git Diff'],
\ 'f' : ['Gfetch', 'Git Fetch'],
\ 'F' : ['Gpull', 'Git Pull'],
\ 'P' : ['Gpush', 'Git Push'],
\ 'r' : ['Gread', 'Git Reset File'],
\ 's' : ['Gstatus', 'Git Status'],
\ }
"----- Testing
let g:lmap.t = { 'name' : 'Testing',
\ 'n' : ['TestNearest', 'Nearest'],
\ 'f' : ['TestFile', 'File'],
\ 's' : ['TestSuite', 'Suite'],
\ 'l' : ['TestLast', 'Last'],
\ 'v' : ['TestVisit', 'Visit Last'],
\ }
"----- Quit
let g:lmap.q = { 'name' : '+ Quit',
\ 'q' : ['qa', 'Quit All'],
\ 'Q' : ['qa!', 'Force Quit All'],
\ }
I was hoping you might be able to pick something out that isn't going to work.
If not maybe i'll just try remapping everything the way you suggest in the readme instead of this 'old way'.
Every time I start my neovim with this config
let mapleader = "\<Space>"
let g:lmap = {}
let g:lmap.c = 'NERDCommenter'
call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
I got
E117: Unknown function: leaderGuide#register_prefix_description
Hey there, first off - thanks for taking the time to make this ๐
I've been keen to try it out but I'm having some issues getting it to display any shortcuts.
I don't think it's a config issue as vim-which-key is working fine with an almost identical config.
let g:lmap = {}
let g:lmap.t = 'test'
let g:lmap.l = {'name' : 'language'}
let g:lmap.l.p = 'prettier'
nnoremap <space> <Nop>
map <space> <leader>
imap jj <Esc>
nmap <leader>lp :CocCommand prettier.formatFile<CR>
call leaderGuide#register_prefix_descriptions("<space>", "g:lmap")
nnoremap <silent> <leader> :<c-u>LeaderGuide '<space>'<CR>
I have been trying to make this plugin configuration using lua, but simply not working. This is my configuration:
local leader_map = {}
leader_map["lsp"] = {
name = 'lsp'
}
api.nvim_set_keymap('n', '<LEADER>', ':<c-u>LeaderGuide \'<Space>\'<CR>', {silent = true})
api.nvim_set_keymap('v', '<LEADER>', ':<c-u>LeaderGuideVisual \'<Space>\'<CR>', {silent = true})
print(vim.inspect(leader_map))
vim.fn['leaderGuide#register_prefix_descriptions']("<Space>", leader_map)
The plugin calls references to the functions nvim_create_buf
and nvim_create_win
which do not seem to exist in Vim, causing the plugin to error out upon the first call of leaderGuide#start_by_prefix
. I am assuming these are defined in NVim and that this is why it is incompatible. Is there an alternative that will accomplish the same goal in Vim, and are there other incompatibilities elsewhere?
Provide an example how to handle keys like
<leader><BS> :nohlsearch<CR>
let g:lmap['<BS>'] = 'Turn of highlight for search results'
I think it's self explanatory. It took me a time to understand how to handle key names like <BS>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.