LazyVim
LazyVim的安装和使用
Pre Install
安装一个Nerd font
unzip ~/TOOL/xxx.zip -d ~/.local/share/fonts/
fc-cache -fv
安装一个node.js
cd ~/TOOL
unzip node-xxx.zip
安装neovim
please install the latest version from github
安装一些工具
sudo apt install xclip
sudo apt install ripgrep
sudo apt install fd-find
Install
从github安装LazyVim
一些细节
lazyVim有一个自动的关于clipboard的设置如下:
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard
即如果不在ssh则自动启用clipboard
自己新添加的设置还是放在~/.config/nvim/init.lua里面。
# support directly copy to clipboard by vim's y command. (actually lua code)
vim.opt.clipboard = "unnamedplus"
如果你的工作环境不支持X11Forwarding
根据你的终端选择以下几种方式复制(用鼠标吧同志)
Depending on your terminal, doing one of the following will allow you to select text that's being displayed in the terminal:
- holding alt and dragging
- holding shift and dragging
- middle/right click dragging
什么,这是压缩毛巾,你坚持不用鼠标?
OSC52方式一满足你的需求:
请注意,使用方式一时,用p去粘贴会怪怪的,可以暂时直接用Ctrl+V(毕竟Ctrl+X被设置成了V-BLOCK)
再次注意,方式一跟LazyVim内部的autocmds有冲突(autocmds似乎会在按下"o"和"i"的时候使用"+"或者"*"寄存器)
# add to your init.lua
vim.g.clipboard = {
name = 'OSC 52',
copy = {
['+'] = require('vim.ui.clipboard.osc52').copy('+'),
['*'] = require('vim.ui.clipboard.osc52').copy('*'),
},
paste = {
['+'] = require('vim.ui.clipboard.osc52').paste('+'),
['*'] = require('vim.ui.clipboard.osc52').paste('*'),
},
}
没关系,我们还有OSC52方式二,将以下内容添加到自己的~/.config/nvim/lua/config/autocmds.lua中(将方式一对init.lua的改变注释掉)
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
local copy_to_unnamedplus = require("vim.ui.clipboard.osc52").copy("+")
copy_to_unnamedplus(vim.v.event.regcontents)
local copy_to_unnamed = require("vim.ui.clipboard.osc52").copy("*")
copy_to_unnamed(vim.v.event.regcontents)
end,
})
迁移
迁移的时候,Mason可能会出问题,EACCESS permission denied!
首先,需要修改$HOME/.local/share/nvim/mason/packages/lua-language-server/lua-language-server
这个文件中调用lua-language-server的路径,以支持lua语言
然后,需要修改$HOME/.local/share/mason/bin/
中的文件,全都是符号链接
使用以下脚本change_link.sh:
#!/bin/bash
# 要处理的目录
target_dir="$HOME/.local/share/nvim/mason/bin"
for symlink in "$target_dir"/*; do
if [ -L "$symlink" ]; then
target_path=$(readlink "$symlink")
if [[ "$target_path" == *".local/share"* ]]; then
new_target_path=$(echo "$target_path" | sed "s|.*/.local/share|$HOME/.local/share|")
echo "Old Path: $target_path"
echo "New Path: $new_target_path"
ln -sf "$new_target_path" "$symlink"
fi
fi
done
tmux的安装和使用
vim还是要和tmux一起用。
直接使用包管理器安装tmux即可。
目前使用的具体配置如下:
set-option -ga terminal-overrides ",xterm-256color:Tc"
set -g default-terminal "xterm-256color"
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'"
# this is done by vim-tmux-navigator. But I want to use Alt here(v-t-nvgtr use Ctrl).
bind-key -n 'M-h' if-shell "$is_vim" 'send-keys c-h' 'select-pane -L'
# select-pane -d is not right! for it set cur window inactive
bind-key -n 'M-j' if-shell "$is_vim" 'send-keys c-j' 'select-pane -D'
bind-key -n 'M-k' if-shell "$is_vim" 'send-keys c-k' 'select-pane -U'
bind-key -n 'M-l' if-shell "$is_vim" 'send-keys c-l' 'select-pane -R'
# Change Some keymap
setw -g mouse on
set -g focus-events on
setw -g aggressive-resize on
set -s escape-time 10
set -g pane-border-style fg=colour240
set -g pane-active-border-style fg=colour33
set-option -g status-position bottom
set-option -g status-left-length 100
set-option -g status-right-length 200
set-option -g status-left " #[fg=#cba6f7]#{session_name} "
set-option -g status-interval 600 # 10 minutes
set-option -g status-right "#[fg=white]#{pane_title} #[fg=#f38ba8]Beijing: #( TZ="Asia/Shanghai" date +%%H:%%M )"
set-option -g status-style "fg=#7C7D83 bg=default"
set-option -g window-status-format "#{window_index}:#{pane_current_command} "
set-option -g window-status-current-format "#[fg=#f38ba8]#{window_index}#[fg=#7ec9d8]:#{pane_current_command} "
set-option -g window-status-activity-style none