Hello, I'd like to know if it's possible to scroll up or down the quick info that shows up for methods and stuff. I'm new to Vim so I'm trying to get some of the functionality I'm used to having in VS Code.
Okay, answering my own question here. I'm excited to have finally found a solution.
So, if you're using the COC plugin for vim/neovim, add the following lines to your vim config file (.vimrc or init.vim) and you'll be able to scroll through the quick info menu using CTRL-F and CTRL-B for those long method docs.
" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
I'm still open to learning an alternative way, but this will do for now.
Related
I'm facing the problem that my init.vim becomes not highlighted properly after the line with lua << EOF in NeoVim. The weird behaviour is 1) paired brackets are colored differently; 2) After lua << EOF a Lua context does begin, yet it doesn't seem to be ended after the next EOF, instead it continues being highlighted in a Lua syntax (all lines later on are affected). From the screenshot below you can see that the brackets in line 59 are displayed as white and red separately, and the Lua syntax stays after line 60.
The code itself is assumed as okay, since it can be sourced without any error or warning, and the editing functions normally. It should namly only be a problem with the highlighting.
Sadly I can't tell the context of this problem. I first noticed it today without doing anything special (e.g. installing a new plugin) and I'm not sure when it occured. I have no clue what is causing this, even after doing research on Google for more than one hour - I haven't seen any post describing a similar situation.
The problem remains with the default color scheme.
I was guessing the CoC extension coc-vimlsp could be relevant, but the problem remains after I disabled it. Otherwise I can't remember any NeoVim plugin that could have something to do with the highlighting.
EDIT: I noticed that the broken highlighting after EOF is relevant to the broken brackets. If I write no brackets in the heredoc block, the highlighting will work correctly. Looks like the Lua highlighting remains after the heredoc block because it thinks the brackets aren't closed properly. And this is only about round brackets (), other brackets like [] {} "" would cause no problem.
My init.vim:
" Indentation
set shiftwidth=4
set ai
set si
" Show line numbers
set nu
" Show command at the bottom right of the screen
set sc
" Limit the number of items shown in popup
set ph=20
" Set the minimal number of lines below the cursor
set so=15
" Disable auto comment insertion
au Filetype * setlocal fo-=c fo-=o fo-=r
" vim-plug config
call plug#begin()
" Themes
Plug 'catppuccin/nvim', {'as': 'catppuccin'}
Plug 'tiagovla/tokyodark.nvim'
" Icon support
Plug 'ryanoasis/vim-devicons'
" Statusbar
Plug 'nvim-lualine/lualine.nvim'
" Fish support
Plug 'dag/vim-fish'
" Makrdown support
Plug 'preservim/vim-markdown'
" Markdown preview
Plug 'iamcco/markdown-preview.nvim', { 'for': ['markdown', 'vim-plug'] }
" TeX support
Plug 'lervag/vimtex'
" Auto close XML-like tags
Plug 'alvan/vim-closetag'
" Auto close brackets
Plug 'jiangmiao/auto-pairs'
" CoC completion engine
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
call plug#end()
" catppuccin config
let g:catppuccin_flavour = "mocha" " latte, frappe, macchiato, mocha
lua << EOF
require("catppuccin").setup()
EOF
" Set colorscheme
colorscheme catppuccin
" lualine config
lua << EOF
require('lualine').setup({
options = {
theme = "horizon"
}
})
EOF
" vim-markdown config
let g:tex_conceal = ""
let g:vim_markdown_math = 1
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_new_list_item_indent = 0
" Enable vimtex for Markdown files
" Not ideal, since this enables ALL features of vimtex
au Filetype md,markdown call vimtex#init()
" VimTeX config
let g:vimtex_compiler_latexmk = {'continuous': 0}
" CoC config
exe 'so ~/.config/nvim/coc_config.vim'
Operating system: MacOS Monterey 12.4
Output of nvim -v:
NVIM v0.8.0
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew#Monterey
Features: +acl +iconv +tui
See ...
The issue raised in both of Neovim and Vim repository.
Neovim side: https://github.com/neovim/neovim/issues/20456
Vim side: https://github.com/vim/vim/issues/11277
Workaround from the comment: reverting to v0.7.2 lua syntax:
curl -sS https://raw.githubusercontent.com/neovim/neovim/v0.7.2/runtime/syntax/lua.vim > $VIMRUNTIME/syntax/lua.vim
When doing a std::cout << "Start" << std::endl; in vscode for Mac it always prints #"Start\r\n" to the debug console.
Is there a way to get rid of the #"\r\n" characters so that it would only print Start?
Best, Hu
You probably currently using llbd , try using externalConsole instead, by adding "externalConsole": true to launch.json, which will send the output to a separate terminal window.
I'm using the vim mode and would like to change the behavior of 'j' to 'gj' and 'k' to 'gk'. I tried using the following:
editor.commands.bindKey("j", null);
editor.commands.bindKey("j", "golinedown");
But 'j' still has the default behavior of going to the next line in the file (rather than the next line on screen). As a workaround, I'm currently using:
editor.commands.bindKey("cmd-j", "golinedown");
which works since cmd-j isn't used for anything else. How can I change the default key binding for 'j','k'?
vim keybindings have different format than the default ace keybinding, and because of that they use their own api Vim.map similar to the :map command in vim
Vim = require("ace/keyboard/vim").Vim
Vim.map("j", "gj", "normal")
Vim.map("k", "gk", "normal")
Note that vim keybinding is not included in ace.js and is loaded asynchronously, so you need to run this code after that file is loaded, which can be done either by loading the keybinding-vim.js script, using config.loadModule
ace.config.loadModule("ace/keybinding/vim", function() {
// use Vim here
})
or adding a listener for "load.module" event
ace.config.on("load.module", function(e) {
if (e.name == "ace/keyboard/vim" && e.module.Vim)
// use Vim here
})
I am using the Matrix colorscheme along with CSApprox for my terminal vim.
I can not seem to be able to set the background as transparent. I have tried editing the matrix.vim file but it doesn't make it any better.
here is the matrix.vim
" vim:set ts=8 sts=2 sw=2 tw=0:
"
" matrix.vim - MATRIX like colorscheme.
"
" Maintainer: MURAOKA Taro <koron#tka.att.ne.jp>
" Last Change: 10-Jun-2003.
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = 'matrix'
hi Comment guifg=#226622
hi Constant guifg=#55ff55
hi Special guifg=#44cc44
hi Identifier guifg=#55ff55
hi Statement guifg=#55ff55 gui=bold
hi PreProc guifg=#339933
hi Type guifg=#55ff55 gui=bold
hi Underlined guifg=#55ff55 gui=underline
hi Error guifg=#55ff55
hi Todo guifg=#113311 gui=none
hi Cursor guifg=#226622
hi lCursor guifg=#226622
hi CursorIM guifg=#226622
hi Directory guifg=#55ff55
hi DiffAdd guifg=#55ff55 gui=none
hi DiffChange guifg=#55ff55 gui=none
hi DiffDelete guifg=#113311 gui=none
hi DiffText guifg=#55ff55 gui=bold
hi ErrorMsg guifg=#55ff55
hi VertSplit guifg=#339933
hi Folded guifg=#44cc44
hi FoldColumn guifg=#44cc44
hi IncSearch guifg=#226622 gui=none
hi LineNr guifg=#44cc44 gui=none
hi ModeMsg guifg=#44cc44
hi MoreMsg guifg=#44cc44
hi NonText guifg=#44cc44 guibg=NONE ctermbg=none
hi Normal guifg=#44cc44 guibg=NONE ctermbg=none
hi Question guifg=#44cc44
hi Search guifg=#113311 gui=none
hi SpecialKey guifg=#44cc44
hi StatusLine guifg=#55ff55 gui=none
hi StatusLineNC guifg=#113311 gui=none
hi Title guifg=#55ff55 gui=bold
hi Visual guifg=#55ff55 gui=none
hi VisualNOS guifg=#44cc44
hi WarningMsg guifg=#55ff55
hi WildMenu guifg=#226622
and my .vimrc file
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'fatih/vim-go'
Plugin 'vim-airline/vim-airline'
" Plugin 'vim-airline/vim-airline-themes'
Plugin 'airblade/vim-gitgutter'
" Plugin 'altercation/vim-colors-solarized'
Bundle 'morhetz/gruvbox'
Plugin 'tpope/vim-git'
Plugin 'Valloric/YouCompleteMe'
Plugin 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Plugin 'flazz/vim-colorschemes'
Plugin 'godlygeek/csapprox'
call vundle#end()
filetype plugin indent on
syntax on
syntax enable
#...
#...
#...
#...
#...
set t_Co=256
colorscheme matrix
if i enter hi Normal guifg=#44cc44 guibg=NONE ctermbg=none in the command prompt, it looks as expected. but not when it's only declared in matrix.vim. i also tried adding it after colorscheme matrix in .vimrc, but it does not help.
How it looks like when first loaded.
How it looks like after i enter command
You don't have to change anything in your colorscheme just add the following to your .vimrc:
hi Normal guibg=NONE ctermbg=NONE
Update:
As Liam mentioned in the comments:
This line needs to go below the colorscheme in .vimrc
If you load a plugin at line 5 of your .vimrc for example, then if you change line 6, it doesn't mean that Vim load the plugin completely and then run your line 6!!
That's why, you should use autocmd command, because in this case, it ensures that all of your plugins are loaded completely and then your command will run after that!
In this case:
" transparent bg
autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE
" For Vim<8, replace EndOfBuffer by NonText
autocmd vimenter * hi EndOfBuffer guibg=NONE ctermbg=NONE
Now you sure that after all the things are loaded, you are running your commands.
Use this gist.
I compile some settings to make vim transparent.
The answers above don't solve all the problems, they change the bg to transparent when we enter vim (hence the "VimEnte" event) but when you source your init.vim file again, the background reverts back (this is because when the file is sourced the VimEnter auto command is not executed).
Instead of directly posting the correct answer, I'll explain how to reach it:
So, First, we need to understand what happens when vim is open:
vi -V10debug.log +q
This will create a debug.log where you can see what auto commands are executed and their order.
autocmd vimenter * hi Normal guibg=NONE ctermbg=NONE
" For Vim<8, replace EndOfBuffer by NonText
autocmd vimenter * hi EndOfBuffer guibg=NONE ctermbg=NONE```
If we are using this, we see in the log that VimEnter change the bg to NONE (so far its good).
But, and the following command opens vim, then source the vimrc and then exit (for faster finding I have putted some print statements)
vi -V10debug_so.log +'!echo sourcing' +'source ~/.config/nvim/init.vim' +'!echo sourced' +q
In the new log, we see, after so VimEnter is not called again and the bg is reverted back to theme default.
But, We also can notice when a file is sourced there are some events that occur, we will focus on the following
SourcePre - before sourcing
SourcePost - after sourcing
There the above incomplete solutions can be fixed using the SourcePost event. so the new and correct autocommand is (Final Answer)
" Workaround for creating transparent bg
autocmd SourcePost * highlight Normal ctermbg=NONE guibg=NONE
\ | highlight LineNr ctermbg=NONE guibg=NONE
\ | highlight SignColumn ctermbg=NONE guibg=NONE
Always use this in a group, see this for as reference - https://github.com/kalkayan/dotfiles/blob/main/.config/nvim/init.vim
In my case, I've just added this 2 line just after the colorscheme declaration :
hi NonText ctermbg=none
hi Normal guibg=NONE ctermbg=NONE
I use macvim, and the hi Normal guibg=NONE ctermbg=NONE don't work for me even I put it after the colorscheme in .vimrc
But I found :set transparency=20 | :set blurradius=90 work quite good for me. From the help of macvim, they do state that this two commands are {not in Vi} and {only in MacVim GUI}.
Pure LUA version for NeoVim to set fully-transparent background:
vim.api.nvim_set_hl(0, "Normal", {guibg=NONE, ctermbg=NONE})
I try to use following configuration:
vmap <C-q> c<ESC>"+p
imap <C-q> <ESC>"+pa
or
imap <C-q> "+gP
nmap <C-q> "+gP
but it seemed to have no effect and reported the "E73: tag stack empty" error.
Does it conflict with any plugins?
I am guessing that you have set
:set cb=unnamed
so that "+ gets set to the default (unnamed) register. Then c in Visual mode will copy the changed text to the + register, right before you try to put it. Try
:vmap <C-q> "_c<ESC>"+p
:help v_c
which sends the deleted text to the black-hole register (like /dev/null).
Your first :imap and your :nmap work for me. The second :imap inserts a literal '"+gP'; was something lost in the formatting of your question?