From 444cc9f004d79274ff85ef0256dbea2909e41ffb Mon Sep 17 00:00:00 2001 From: u2 Date: Tue, 20 May 2025 08:18:55 +0000 Subject: [PATCH] add vim&tmux conf --- confs/.tmux.conf | 2 + confs/.vimrc | 181 +++++++++++++++++++++++++++++++++++++++++++++++ doc/main.tex | 16 ++++- 3 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 confs/.tmux.conf create mode 100644 confs/.vimrc diff --git a/confs/.tmux.conf b/confs/.tmux.conf new file mode 100644 index 0000000..adb4eb7 --- /dev/null +++ b/confs/.tmux.conf @@ -0,0 +1,2 @@ +set-option -g prefix C-a +set -s set-clipboard on diff --git a/confs/.vimrc b/confs/.vimrc new file mode 100644 index 0000000..29223e1 --- /dev/null +++ b/confs/.vimrc @@ -0,0 +1,181 @@ +call plug#begin() + +Plug 'tpope/vim-fugitive' +Plug 'tpope/vim-commentary' +Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } + +" Plug 'neoclide/coc.nvim', {'branch': 'release'} + +Plug 'jpalardy/vim-slime' + +Plug 'ojroques/vim-oscyank', {'branch': 'main'} + +call plug#end() + +nnoremap n :NERDTreeFocus +nnoremap :NERDTree +nnoremap :NERDTreeToggle +nnoremap :NERDTreeFind + + +set backspace=indent,eol,start +set mouse=r + +packadd termdebug +let g:termdebug_wide=1 +let g:termdebugger='riscv32-unknown-elf-gdb' + + +" Disable compatibility with vi which can cause unexpected issues. +set nocompatible + +" Enable type file detection. Vim will be able to try to detect the type of file in use. +filetype on + +" Enable plugins and load plugin for the detected file type. +filetype plugin on + +" Load an indent file for the detected file type. +filetype indent on + +" Turn syntax highlighting on. +syntax on + +" Add numbers to each line on the left-hand side. +set number + +" Highlight cursor line underneath the cursor horizontally. +set cursorline + +" Highlight cursor line underneath the cursor vertically. +"set cursorcolumn + + +" Set shift width to 4 spaces. +set shiftwidth=4 + +" Set tab width to 4 columns. +set tabstop=4 + +" Use space characters instead of tabs. +set expandtab + +" Do not save backup files. +set nobackup + +" Do not let cursor scroll below or above N number of lines when scrolling. +set scrolloff=10 + +" Do not wrap lines. Allow long lines to extend as far as the line goes. +set nowrap + +" While searching though a file incrementally highlight matching characters as you type. +set incsearch + +" Ignore capital letters during search. +set ignorecase + +" Override the ignorecase option if searching for capital letters. +" This will allow you to search specifically for capital letters. +set smartcase + +" Show partial command you type in the last line of the screen. +set showcmd + +" Show the mode you are on the last line. +set showmode + +" Show matching words during a search. +set showmatch + +" Use highlighting when doing a search. +set hlsearch + +" Set the commands to save in history default number is 20. +set history=1000 + +" Enable auto completion menu after pressing TAB. +set wildmenu + +" Make wildmenu behave like similar to Bash completion. +set wildmode=list:longest + +" There are certain files that we would never want to edit with Vim. +" Wildmenu will ignore files with these extensions. +set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx + + +" set colorscheme OceanicNext + + +if !exists("g:slime_python_ipython") + let g:slime_python_ipython = 1 +endif + +let g:slime_target = "tmux" + +" Run cell for vim-slime +function! SendCell(pattern) + let start_line = search(a:pattern, 'bnW') + + if start_line + let start_line = start_line + 1 + else + let start_line = 1 + endif + + let stop_line = search(a:pattern, 'nW') + if stop_line + let stop_line = stop_line - 1 + else + let stop_line = line('$') + endif + + call slime#send_range(start_line, stop_line) +endfunction + +" Custom vim-slime mappings +let g:slime_no_mappings = 1 +xmap SlimeRegionSend +nmap :call SendCell('^#%%') +nmap v SlimeConfig + + +nmap c OSCYankOperator +nmap cc c_ +vmap c OSCYankVisual + +if (!has('nvim') && !has('clipboard_working')) + " In the event that the clipboard isn't working, it's quite likely that + " the + and * registers will not be distinct from the unnamed register. In + " this case, a:event.regname will always be '' (empty string). However, it + " can be the case that `has('clipboard_working')` is false, yet `+` is + " still distinct, so we want to check them all. + let s:VimOSCYankPostRegisters = ['', '+', '*'] + function! s:VimOSCYankPostCallback(event) + if a:event.operator == 'y' && index(s:VimOSCYankPostRegisters, a:event.regname) != -1 + call OSCYankRegister(a:event.regname) + endif + endfunction + augroup VimOSCYankPost + autocmd! + autocmd TextYankPost * call s:VimOSCYankPostCallback(v:event) + augroup END +endif + +set tags=./tags;,tags; +" Map Ctrl-[ to go back in the tag stack + +" Function to display filename aligned to the right +function! ShowFileNameRight() + let l:filename = expand('%:p') + let l:columns = &columns + let l:space = l:columns - len(l:filename) - 2 + let l:spaces = repeat(' ', l:space > 0 ? l:space : 0) + echo l:spaces . l:filename +endfunction + +" Autocommand to display filename in command area when entering command mode +" autocmd CmdlineEnter * call ShowFileNameRight() + + diff --git a/doc/main.tex b/doc/main.tex index 43346e5..28c8e78 100644 --- a/doc/main.tex +++ b/doc/main.tex @@ -94,6 +94,20 @@ incus exec dnsmasq-container -- usermod -aG sudo user incus exec dnsmasq-container -- usermod -aG docker user \end{lstlisting} +After creating the user, you can also transfer configuration files such as \texttt{.tmux.conf} and \texttt{.vimrc} from your local machine to the home directory of the newly created user inside the container: + +\begin{lstlisting}[language=bash] +incus file push .tmux.conf dnsmasq-container/home/user/ +incus file push .vimrc dnsmasq-container/home/user/ +\end{lstlisting} + +To enhance the functionality of Vim, it's recommended to install a plugin manager such as \texttt{vim-plug}. This can be done by downloading the plugin manager directly into the user's Vim configuration directory using the following command: + +\begin{lstlisting}[language=bash] +curl -fLo ~/.vim/autoload/plug.vim --create-dirs \\ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +\end{lstlisting} + \subsection{Accessing the Container} Access the container's shell: \begin{lstlisting}[language=bash] @@ -194,4 +208,4 @@ If \texttt{dnsmasq} fails to start: \section{Conclusion} This guide configures \texttt{dnsmasq} as a DNS and DHCP server in an Incus container on Debian. The Netplan configuration ensures proper network setup. For advanced configurations, refer to the \texttt{dnsmasq} documentation (\texttt{man dnsmasq}). -\end{document} \ No newline at end of file +\end{document}