Skip to main content

One post tagged with "Tool"

Tool for developer

View All Tags

Intro Vim editor - Lazy Vim

ยท 5 min read
Hieu Nguyen
Senior Software Engineer

What is Vim?โ€‹

Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as "vi" with most UNIX systems and with Apple OS X.

What is the LazyVim?โ€‹

LazyVim is a Neovim setup powered by ๐Ÿ’ค lazy.nvim to make it easy to customize and extend your config.

What is Tmux?โ€‹

Tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.

Installationโ€‹

Install Nvimโ€‹

Nvim is based on Vim by Bram Moolenaar. Nvim is emphatically a fork of Vim, not a clone: compatibility with Vim (especially editor and Vimscript features, except Vim9script) is maintained where possible. See vim-differences for the complete reference.

Install Nvim

On Linux

curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz

sudo rm -rf /opt/nvim-linux-x86_64

sudo tar -C /opt -xzf nvim-linux-x86_64.tar.gz

Add to file ~/.bashrc


export PATH="$PATH:/opt/nvim-linux-x86_64/bin"

Check again

nvim --version


# Output

NVIM v0.11.4
Build type: Release
LuaJIT 2.1.1741730670
Run "nvim -V1 -v" for more info

Install LazyVimโ€‹

Install LazyVim

Backup old Neovim

# required
mv ~/.config/nvim{,.bak}

# optional but recommended
mv ~/.local/share/nvim{,.bak}
mv ~/.local/state/nvim{,.bak}
mv ~/.cache/nvim{,.bak}

Install Lazzy Vim

git clone https://github.com/LazyVim/starter ~/.config/nvim

rm -rf ~/.config/nvim/.git

Start Neovim, and waitin to LazyVim finish setup.

nvim

Install Tmuxโ€‹

Install Tmux

On debian

sudo apt install tmux

Install Tmux Plugin Manager. Custome your tmux (if you need or skip -> jump to next step, it not required)

Install Tmux Plugin Manager

My config tmux. You can copy and put to file ~/.tmux.conf or reference at tmux-plugin

# .tmux.conf

set -g default-terminal 'screen-256color'
set -g status-style 'bg=#1e1e2e'

setw -g mode-keys vi
bind-key h select-pane -L
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R

bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r H resize-pane -L 5
bind -r L resize-pane -R 5

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'

# theme
set -g @plugin 'dracula/tmux'
# set -g @dracula-plugins 'cpu-usage ram-usage'
# set -g @dracula-cpu-usage-colors 'pink dark-gray'
set -g @dracula-show-powerline true
set -g @dracula-show-flags true
set -g @dracula-show-left-icon session
set -g @dracula-cpu-display-load true
set -g @dracula-plugins "cpu-usage ram-usage"
# per default available colors: white, gray, dark_gray, light_purple, dark_purple, cyan, green, orange, red, pink, yellow
# set -g @dracula-[plugin-name]-colors "[background] [foreground]"
set -g @dracula-cpu-usage-colors "pink dark_gray"
# the default is 5, it can accept any number
set -g @dracula-refresh-rate 5
set -g @dracula-border-contrast true
set -g @dracula-transparent-powerline-bg true
# default is 1, it can accept any number and 0 disables padding.
set -g @dracula-left-icon-padding 0
set -g @dracula-show-battery-status true
set -g @dracula-time-format "%F %R"
set -g status-position top


# neovim
set -g @plugin 'christoomey/vim-tmux-navigator'

set -g @vim_navigator_mapping_left "C-Left C-h" # use C-h and C-Left
set -g @vim_navigator_mapping_right "C-Right C-l"
set -g @vim_navigator_mapping_up "C-k"
set -g @vim_navigator_mapping_down "C-j"
set -g @vim_navigator_mapping_prev "" # removes the C-\ binding

set -g @vim_navigator_prefix_mapping_clear_screen ""


set -g @plugin 'laktak/extrakto'
set -g @plugin 'rickstaa/tmux-notify'
set -g @plugin 'sainnhe/tmux-fzf'
set -g @plugin 'AngryMorrocoy/tmux-neolazygit'

## config auto reopen session
#set -g @plugin 'tmux-plugins/tmux-resurrect'
#set -g @plugin 'tmux-plugins/tmux-continuum'

#set -g @continuum-restore 'on'
#set -g @continuum-boot 'on'


# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

On Terminal

Start tmux

tmux 

Ctrl b -> Shift + i => To install plugin Ctrl b -> Shift + u -> all -> To update all plugin

Ctrl b: is default prefix. You can change with config

# ~/.tmux.conf
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix

Basicโ€‹

Keymapsโ€‹

Keymaps

Pluginโ€‹

Plugin

Config Nvim for tmuxโ€‹

# ~/.config/nvim/lua/plugins

return {
{
"christoomey/vim-tmux-navigator",
cmd = {
"TmuxNavigateLeft",
"TmuxNavigateDown",
"TmuxNavigateUp",
"TmuxNavigateRight",
"TmuxNavigatePrevious",
"TmuxNavigatorProcessList",
},
keys = {
{ "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
{ "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
{ "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
{ "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
},
},
}

Install plugin for nvim

nvim

# Press l -> Shift u -> Shift s


Why I choose LazyVim and Tmux?โ€‹

Thank for reading!โ€‹