Posts with tag neovim

flash.nvim with Neovim from Zero

2025-07-05
25flash.nvimlazy.nvimneovimvimvim-search

vim 模式下,想要跳转到屏幕上某个随机位置,并不是很方便. flash.nvim 是一个理想选择,与 easymotion, leap.nvim 相似但是更符合直觉.本文假设你:已经安装了 neovim可能仅使用 neovim 的 init.vim可能用过 easymotionflash.nvim 效果展示假设当前状态如下,光标在第 18 行,你想跳到第一个 neovim:按下 / n e o 后,会在所有匹配 neo 的地方显示一个标识字母,按下 q 跳转到第一个 neo 处:其实打下 / n 就会开始匹配,你输入几个字母就匹配几个字母. 原有的 / 搜索功能不受影响.如何安装 (Starting from installing lazy.nvim)注意 init.vim 和 init.lua 不能共存.将你的 init.vim 改名为 init2.vim.创建 init.lua,添加如下内容,它会加在你的 init2.vim,并安装 lazy.nvim 和 flash.nvim.local vimrc = vim.fn.stdpath("config") .. "/init2.vim" vim.cmd.source(vimrc) -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then vim.api.nvim_echo({ { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { out, "WarningMsg" }, { "\nPress any key to exit..." }, }, true, {}) vim.fn.getchar() os.exit(1) end end vim.opt.rtp:prepend(lazypath) -- Make sure to setup `mapleader` and `maplocalleader` before -- loading lazy.nvim so that mappings are correct. -- This is also a good place to setup other settings (vim.opt) vim.g.mapleader = " " vim.g.maplocalleader = "\\" -- Setup lazy.nvim require("lazy").setup({ spec = { -- add your plugins here -- [flash.nvim] { "folke/flash.nvim", event = "VeryLazy", ---@type Flash.Config opts = { modes = { search = { enabled = true } } }, -- stylua: ignore keys = { { "s", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, }, } }, -- Configure any other settings here. See the documentation for more details. -- colorscheme that will be used when installing plugins. install = { colorscheme = { "habamax" } }, -- automatically check for plugin updates checker = { enabled = true }, }) 基于 flash.nvim 文档改动. search = { enabled = true } 这一行开启了 search 增强.<c-s> 似乎是用于 Toggle flash.nvim.添加上述脚本后,重新启动 nvim,会弹出安装窗口,过一会儿就装好了.其他功能flit 功能推荐. 这是默认开启的,可以增强你的 f 和 F.比如你正常地 f{,你就会跳到后面第一个 {(允许跨行)此时第一个 { 后所有的 { 都会高亮,如果你想跳到的其实是第三个 {,那么再按两次 f.不喜欢这个功能的话上面配置里的 opts = {} 可以加入:opts = { modes = { char = { enabled = false } } },treesitter 功能推荐. 在支持 treesitter 的环境下按下 s 可以显示附近作用域的首尾,按下 label 跳转过去.remote 功能不推荐,会 Ctrl + O 就用不着. 所以上面配置中我没有引入该功能.Postscript搜索功能正常支持中文字符.vim 插件我认为应该和 vim 原有键位贴近,不能离开了这个功能就不会用 vim 了,毕竟我们经常要在新电脑上用 vi 编辑东西.如果 git clone failed / checkout failed,可以尝试 .gitconfig 中加入 URL 替换 (works on my mac m1).[url "[email protected]:"] insteadOf = https://github.com/ [url "[email protected]:"] insteadOf = git://githu

nvim-and-packer-old

2024-01-15
neovimsoftwares-and-tools

使用系统粘贴板in init.vim:set clipboard=unnamedplus~/.config/nvimnvim ├── init.vim └── lua └── plugins.lua注意在 init.vim 中加入 lua 语句:lua require('plugins')其中的 plugins.lua 来自https://github.com/wbthomason/packer.nvim在 Packer plugins.lua 中加入新的插件在 return 的内部而不是外部: use({ 'rose-pine/neovim', as = 'rose-pine' }) vim.cmd('colorscheme rose-pine')fish 没有高亮nvim 版本太低如果装了 Packer 以后一进 nvim 就报错Error detected while processing /home/strife/.local/share/nvim/plugged/nvim-treesitter/plugin/nvim-treesitter.lua: E5113: Error while calling lua chunk: .../plugged/nvim-treesitter/lua/nvim-treesitter/configs.lua:104: attempt to call field 'nvim_create_augroup' (a nil value)这是因为 nvim 版本太低再装一个 vim-plughttps://github.com/junegunn/vim-plug然后再装一个多光标https://github.com/mg979/vim-visual-mult

default-init-vim

2024-01-15
neovimsoftwares-and-tools

" Configuration file for vim set modelines=0 " CVE-2007-2438 " Normally we use vim-extensions. If you want true vi-compatibility " remove change the following statements set nocompatible " Use Vim defaults instead of 100% vi compatibility set backspace=2 " more powerful backspacing " Don't write backup file if vim is being called by "crontab -e" au BufWrite /private/tmp/crontab.* set nowritebackup nobackup " Don't write backup file if vim is being called by "chpass" au BufWrite /private/etc/pw.* set nowritebackup nobackup " 自定义设置 " set mouse=a let skip_defaults_vim=1 syntax enable " 打开语法高亮 syntax on " 开启文件类型侦测 colorscheme desert " 着色模式:灰色背景 set guifont=Monaco:h14 set autoindent " 自动对齐 set backspace=2 " 设置退格键可用 set cindent shiftwidth=4 " 自动缩进4空格 set smartindent " 智能自动缩进 set ai! " 设置自动缩进 set nu! " 显示行号 set showmatch " 显示括号配对情况 " set mouse=a " 启用鼠标 set ruler " 右下角显示光标位置的状态行 set incsearch " 查找book时,当输入/b时会自动找到 set hlsearch " 开启高亮显示结果 set incsearch " 开启实时搜索功能 set nowrapscan " 搜索到文件两端时不重新搜索 set nocompatible " 关闭兼容模式 set cursorline " 突出显示当前行 set hidden " 允许在有未保存的修改时切换缓冲区 set list " 显示Tab符,使用一高亮竖线代替 set listchars=tab:\|\ " 显示Tab符,使用一高亮竖线代替 set noswapfile " 设置无交换区文件" set writebackup " 设置无备份文件 set nobackup " 设置无备份文件 set autochdir " 设定文件浏览器目录为当前目录 set foldmethod=syntax " 选择代码折叠类型 set foldlevel=100 " 禁止自动折叠 set laststatus=2 " 开启状态栏信息 set cmdheight=2 " 命令行的高度,默认为1,这里设为2 set showtabline=2 " 设置默认显示标签 set clipboard+=unnamed " 与系统公用剪贴板 set autoread " 当文件在外部被修改,自动更新该文件 set scrolloff=5 " 设定光标离窗口上下边界 5 行时窗口自动滚动 set guioptions-=T " 去掉上方工具栏 set autochdir " 自动切换到当前目录" set autoread " 自动检测并加载外部对文件的修改" set autowrite " 自动检测并加载外部对文件的修改" set showcmd " 命令栏显示命令 " set ignorecase smartcase " 搜索时智能忽略大小写 set tabstop=4 " (ts) 设置一个 <tab> 显示为多少个空格 set expandtab " (et) 把 <tab> 转换为空格 set shiftwidth=4 " (sw) 设置自动缩进的宽度(以及 << 和 >> 命令) set number set relativenumber " [总是使用系统粘贴板] set clipboard=unnamedplus " [删除而不是剪切] nnoremap d "_d vnoremap d "_d nnoremap D "_D vnoremap D "_D nnoremap c "_c vnoremap c "_c nnoremap C "_C vnoremap C "_C xnoremap p pgvy " [括号补全] inoremap ' ''<ESC>i inoremap " ""<ESC>i inoremap ( ()<ESC>i inoremap [ []<ESC>i inoremap { {}<ESC>i " [vim-plug] call plug#begin() Plug 'mg979/vim-visual-multi', {'branch': 'master'} call plug#end() " [添加 Packer] lua require('plugins'

quick-line-jumps

2024-01-15
neovimsoftwares-and-tools

https://github.com/Houl/repmo-vim/tree/masterput this autoload in your nvim autoloadand paste stuffs like" map a motion and its reverse motion: :noremap <expr> h repmo#SelfKey('h', 'l')|sunmap h :noremap <expr> l repmo#SelfKey('l', 'h')|sunmap l " if you like `:noremap j gj', you can keep that: :map <expr> j repmo#Key('gj', 'gk')|sunmap j :map <expr> k repmo#Key('gk', 'gj')|sunmap k " repeat the last [count]motion or the last zap-key: :map <expr> ; repmo#LastKey(';')|sunmap ; :map <expr> , repmo#LastRevKey(',')|sunmap , " add these mappings when repeating with `;' or `,': :noremap <expr> f repmo#ZapKey('f')|sunmap f :noremap <expr> F repmo#ZapKey('F')|sunmap F :noremap <expr> t repmo#ZapKey('t')|sunmap t :noremap <expr> T repmo#ZapKey('T')|sunmap T " 只记忆 count jumps :let g:repmo_require_count = 1in your init.vim.Usage5j;;;;hjkl;;;It will remember 5j, not one of hjkl.just kidding, although https://www.vim.org/scripts/script.php?script_id=2174 says so, it doesn't seem to work now

No more posts to load.