Giter Site home page Giter Site logo

vim-leader-guide's People

Contributors

adrianstaniec avatar hecal3 avatar metakirby5 avatar spinks avatar svalaskevicius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vim-leader-guide's Issues

Cannot use mapping to lua functions

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

can't get it to work

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.

License

Hi,

could you add a license please?

Migrating from `hecal3/vim-leader-guide`

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'.

Neovim 0.4.4 doesn't recoginze leaderGuide#register_prefix_descriptions

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

Keyboard shortcuts list is empty on Neovim 0.4.3

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>
Here is a gif of the issue

Kapture 2021-03-21 at 13 07 27

Configuration example using Lua?

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)

This is my error screenshoot:
image

Does not work in Vim8

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 <BS>

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>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.