1 Star 0 Fork 0

Eugene/nvim-conf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
init.vim.bak 5.71 KB
一键复制 编辑 原始数据 按行查看 历史
egu0 提交于 2024-07-08 14:19 . common configure & java format
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Up> <Nop>
noremap <Right> <Nop>
" 设置 Leader 键为空格
let mapleader = " "
" 编码方式 UTF-8
set encoding=UTF-8
set fileencoding=utf-8
" jkhl 移动时光标周围保留8行
set scrolloff=8
set sidescrolloff=8
" 显示行号
set number
" 使用相对行号
"set relativenumber
" 高亮所在行
set cursorline
" 显示左侧图标指示列
set signcolumn=yes
" 右侧参考线
set colorcolumn=160
" 缩进字符
set tabstop=2
set softtabstop=2
set shiftwidth=2
set shiftround
" 空格替代
set expandtab
" 新行对齐当前行
set autoindent
set smartindent
" 搜索大小写不敏感,除非包含大写
set ignorecase
set smartcase
" 搜索不要高亮
set nohlsearch
set incsearch
" 命令模式行高
set cmdheight=1
" 自动加载外部修改
set autoread
" 禁止折行
set nowrap
" 光标在行首尾时<Left><Right>可以跳到下一行
set whichwrap+=<,>,[,]
" 允许隐藏被修改过的 buffer
set hidden
" 鼠标支持
set mouse=a
" 禁止创建备份文件
set nobackup
set nowritebackup
set noswapfile
" smaller updatetime
set updatetime=300
" 超时长度
set timeoutlen=500
" 分屏方向
set splitbelow
set splitright
" 自动补全不自动选中
set completeopt=menu,menuone,noselect,noinsert
" 样式
set background=dark
set termguicolors
" 不可见字符的显示
set nolist
set listchars=space:·,tab:>-
" 补全显示
set wildmenu
set shortmess+=c
set pumheight=10
" 剪贴板支持
"set clipboard=unnamedplus
"------------------------------------------------------------------------------
call plug#begin()
Plug 'joshdick/onedark.vim'
Plug 'togglebyte/nvim'
Plug 'morhetz/gruvbox'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
call plug#end()
"------------------------------------------------------------------------------
" 打开水平分割的空窗口
nnoremap <leader>sh :new<CR>
" 打开垂直分割的空窗口
nnoremap <leader>sv :vnew<CR>
" write
nnoremap <leader>ss :w!<CR>
" 快速窗口切换快捷键
"move focus to left window
nnoremap <leader>wh <C-w>h
"move focus to bottom window
nnoremap <leader>wj <C-w>j
"move focus to top window
nnoremap <leader>wk <C-w>k
"move focus to right window
nnoremap <leader>wl <C-w>l
"close window
nnoremap <leader>wc :close<CR>
" 标签页
nnoremap <leader>ta :tabnew<CR>
nnoremap <leader>tn :tabnext<CR>
nnoremap <leader>tp :tabprev<CR>
nnoremap <leader>tf :tabfirst<CR>
nnoremap <leader>tl :tablast<CR>
"------------------------------------------------------------------------------
" 定义函数来运行 cargo fmt 和 cargo check,并显示错误和警告计数
function! CargoFmtCheck()
silent! write
redraw!
echo "Checking..."
redraw!
let l:output = systemlist("cargo fmt && cargo check 2>&1")
let l:warning_count = 0
let l:error_count = 0
let l:qf_list = []
let l:current_file = ''
let l:current_line = 0
let l:current_col = 0
let l:current_message = ''
let l:pattern_file = '^\s*--> \(\S\+\):\(\d\+\):\(\d\+\)'
for l:line in l:output
if l:line =~# '^warning: .* warnings$' || l:line =~# '^error: .* previous error$'
continue
endif
if l:line =~# '^warning:'
let l:warning_count += 1
let l:current_message = l:line
continue
endif
if l:line =~# '^error'
let l:error_count += 1
let l:current_message = l:line
continue
endif
" too complex to continue:
" - collect error information
" - use regular expr
endfor
" 在命令行上显示结果
echo "E:" . l:error_count . " | W:" . l:warning_count
endfunction
" 创建 Vim 命令来调用函数
command! CargoFmtCheck call CargoFmtCheck()
"------------------------------------------------------------------------------
" 设置主题
" togglebit: 可以为 .rs 项目设置
colorscheme togglebit
"colorscheme gruvbox
"------------------------------------------------------------------------------
" 配置 fzf.vim 键位绑定
" 设置 fzf.vim 在分屏中打开文件的行为
let g:fzf_action = {
\ 'enter': 'edit',
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-t': 'tabedit'
\ }
" <leader>ff:查找文件
nnoremap <leader>ff :Files<CR>
" <leader>fg:查找 Git 管理的文件
"nnoremap <leader>fg :GFiles<CR>
" <leader>fl:在打开的文件中搜索内容
nnoremap <leader>fl :Lines<CR>
" <leader>fb:打开的缓冲区
"nnoremap <leader>fb :Buffers<CR>
" <leader>fh:帮助标签
nnoremap <leader>fh :Helptags<CR>
" Windows 命令
"nnoremap <leader>fw :Windows<CR>
" search by 'sudo apt install ripgrep'
nnoremap <leader>rg :Rg<CR>
"---------------------------------------- cargo related keymap
nnoremap <leader>cc :write \| :belowright 10split \| terminal cargo check<CR>
nnoremap <leader>cf :call CargoFmtCheck()<CR>
"---------------------------------------- maven related keymap
function! MavenFormat()
"refer: https://github.com/spotify/fmt-maven-plugin
call jobstart(['mvn', 'compile', 'com.spotify.fmt:fmt-maven-plugin:format'], {'on_exit': {-> execute('edit')}})
endfunction
nnoremap <leader>mf :write \| :call MavenFormat()<CR>
"only show DEBUG level message of mvn output
"https://stackoverflow.com/a/29670780
nnoremap <leader>mc :write \| :belowright 10split \| terminal mvn compile com.spotify.fmt:fmt-maven-plugin:format<CR>
nnoremap <leader>mr :write \| :belowright 10split \| terminal mvn compile exec:java -Dexec.mainClass="com.craftinginterpreters.lox.Lox" -Dexec.args="test.lox"<CR>
nnoremap <leader>mm :write \| :belowright 10split \| terminal mvn compile exec:java -Dexec.mainClass="com.craftinginterpreters.lox.Lox"<CR>
"------------------------------------------------------------
nmap <C-h> :vertical resize -4<CR>
nmap <C-l> :vertical resize +4<CR>
nmap <C-k> :resize +4<CR>
nmap <C-j> :resize -4<CR>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/egu0/nvim-conf.git
[email protected]:egu0/nvim-conf.git
egu0
nvim-conf
nvim-conf
main

搜索帮助