From 2f132784aab54fcaedae6d2c465d32b3185dde7f Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 29 Mar 2023 18:01:18 +0800 Subject: [PATCH] feat(grammarous): add grammarous key bindings --- autoload/SpaceVim/layers/core/statusline.vim | 2 ++ autoload/SpaceVim/layers/edit.vim | 14 ++++++++++++++ .../autoload/grammarous/info_win.vim | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index 9b0338d00..abffc0aee 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -454,6 +454,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort return '%#SpaceVim_statusline_a_bold# Python Doc %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep elseif bufname('%') == '__cheat_output__' return '%#SpaceVim_statusline_a_bold# Vim Cheat %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep + elseif bufname('%') == '[Grammarous]' + return '%#SpaceVim_statusline_a_bold# Grammarous Info %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep elseif &filetype ==# 'gista-list' return '%#SpaceVim_statusline_ia#' \ . s:winnr(1) . '%#SpaceVim_statusline_ia_SpaceVim_statusline_b#' diff --git a/autoload/SpaceVim/layers/edit.vim b/autoload/SpaceVim/layers/edit.vim index 5dd8725db..d59831569 100644 --- a/autoload/SpaceVim/layers/edit.vim +++ b/autoload/SpaceVim/layers/edit.vim @@ -299,6 +299,20 @@ function! SpaceVim#layers#edit#config() abort call SpaceVim#mapping#space#def('nmap', ['x', 'l', 'U'], 'UniquifyCaseSenstiveLines', \ 'uniquify-lines (case-senstive)', 0, 1) + let g:_spacevim_mappings_space.x.g = {'name' : '+Grammarous'} + " | `(grammarous-move-to-info-window)` | Move the cursor to the info window | + " | `(grammarous-open-info-window)` | Open the info window for the error under the cursor | + " | `(grammarous-reset)` | Reset the current check | + " | `(grammarous-fixit)` | Fix the error under the cursor automatically | + " | `(grammarous-fixall)` | Fix all the errors in a current buffer automatically | + " | `(grammarous-close-info-window)` | Close the information window from checked buffer | + " | `(grammarous-remove-error)` | Remove the error under the cursor | + " | `(grammarous-disable-rule)` | Disable the grammar rule under the cursor | + " | `(grammarous-move-to-next-error)` | Move cursor to the next error | + " | `(grammarous-move-to-previous-error)` | Move cursor to the previous error | + call SpaceVim#mapping#space#def('nmap', ['x', 'g', 'n'], '(grammarous-move-to-next-error)', 'move-cursor-to-next-error', 0, 1) + call SpaceVim#mapping#space#def('nmap', ['x', 'g', 'p'], '(grammarous-move-to-previous-error)', 'move-cursor-to-previous-error', 0, 1) + let g:_spacevim_mappings_space.i = {'name' : '+Insertion'} let g:_spacevim_mappings_space.i.l = {'name' : '+Lorem-ipsum'} let g:_spacevim_mappings_space.i.p = {'name' : '+Passwords'} diff --git a/bundle/vim-grammarous/autoload/grammarous/info_win.vim b/bundle/vim-grammarous/autoload/grammarous/info_win.vim index 7821d3e8a..45d656ccc 100644 --- a/bundle/vim-grammarous/autoload/grammarous/info_win.vim +++ b/bundle/vim-grammarous/autoload/grammarous/info_win.vim @@ -133,6 +133,9 @@ endfunction function! grammarous#info_win#open(e, bufnr) execute g:grammarous#info_win_direction g:grammarous#info_window_height . 'new' '[Grammarous]' + " why need this, the statusline is not update when open info win first + " time + doautocmd WinEnter let b:grammarous_preview_original_bufnr = a:bufnr let b:grammarous_preview_error = a:e call setline(1, s:get_info_buffer(a:e)) @@ -145,6 +148,8 @@ function! grammarous#info_win#open(e, bufnr) setlocal bufhidden=hide setlocal buftype=nofile setlocal readonly + setl winfixwidth + setl winfixheight setlocal nolist setlocal nobuflisted setlocal noswapfile