From de616c3fd9f0f3bb41280c1abad56e667290115e Mon Sep 17 00:00:00 2001 From: TBS093A Date: Thu, 27 Apr 2023 19:57:38 +0200 Subject: [PATCH] feat: split configs on directories && add vim config with plugins & mapping integration + guide --- .bash_profile => bash.config/.bash_profile | 0 .bashrc => bash.config/.bashrc | 2 + .gitconfig => git.config/.gitconfig | 0 make.symlinks.sh | 16 +- sshd_config => sshd.ssh.config/sshd_config | 4 +- welcome.sh => sshd.ssh.config/welcome.sh | 0 vim.config/init.vim | 296 ++++++++++++++++++ .zshrc => zsh.config/.zshrc | 4 +- .../install.zsh.plugins.sh | 2 +- install.zsh.sh => zsh.config/install.zsh.sh | 0 .../lambda-00x097.zsh-theme | 0 plugins => zsh.config/plugins | 0 12 files changed, 314 insertions(+), 10 deletions(-) rename .bash_profile => bash.config/.bash_profile (100%) rename .bashrc => bash.config/.bashrc (99%) rename .gitconfig => git.config/.gitconfig (100%) rename sshd_config => sshd.ssh.config/sshd_config (98%) rename welcome.sh => sshd.ssh.config/welcome.sh (100%) create mode 100644 vim.config/init.vim rename .zshrc => zsh.config/.zshrc (97%) rename install.zsh.plugins.sh => zsh.config/install.zsh.plugins.sh (66%) rename install.zsh.sh => zsh.config/install.zsh.sh (100%) rename lambda-00x097.zsh-theme => zsh.config/lambda-00x097.zsh-theme (100%) rename plugins => zsh.config/plugins (100%) diff --git a/.bash_profile b/bash.config/.bash_profile similarity index 100% rename from .bash_profile rename to bash.config/.bash_profile diff --git a/.bashrc b/bash.config/.bashrc similarity index 99% rename from .bashrc rename to bash.config/.bashrc index 9a7af37..ce401dd 100644 --- a/.bashrc +++ b/bash.config/.bashrc @@ -182,3 +182,5 @@ ex () echo "'$1' is not a valid file" fi } + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash diff --git a/.gitconfig b/git.config/.gitconfig similarity index 100% rename from .gitconfig rename to git.config/.gitconfig diff --git a/make.symlinks.sh b/make.symlinks.sh index 1373418..9159337 100755 --- a/make.symlinks.sh +++ b/make.symlinks.sh @@ -4,13 +4,17 @@ rm -r ~/.oh-my-zsh/themes/lambda-00x097.zsh-theme rm -r /etc/updated-motd.d/welcome.sh rm -r /etc/profile.d/welcome.sh rm -r /etc/ssh/sshd_config +rm -r ~/.config/nvim/init.vim +rm -r ~/.config/nvim/init.lua -ln -s $(pwd)/.gitconfig ~/.gitconfig +ln -s $(pwd)/git.config/.gitconfig ~/.gitconfig -ln -s $(pwd)/.zshrc ~/.zshrc -ln -s $(pwd)/lambda-00x097.zsh-theme ~/.oh-my-zsh/themes/lambda-00x097.zsh-theme +ln -s $(pwd)/zsh.config/.zshrc ~/.zshrc +ln -s $(pwd)/zsh.config/lambda-00x097.zsh-theme ~/.oh-my-zsh/themes/lambda-00x097.zsh-theme -ln -s $(pwd)/welcome.sh /etc/updated-motd.d/welcome.sh -ln -s $(pwd)/welcome.sh /etc/profile.d/welcome.sh +ln -s $(pwd)/sshd.ssh.config/welcome.sh /etc/updated-motd.d/welcome.sh +ln -s $(pwd)/sshd.ssh.config/welcome.sh /etc/profile.d/welcome.sh +ln -s $(pwd)/sshd.ssh.config/sshd_config /etc/ssh/sshd_config -ln -s $(pwd)/sshd_config /etc/ssh/sshd_config \ No newline at end of file +ln -s $(pwd)/vim.config/init.vim ~/.config/nvim/init.vim +ln -s $(pwd)/vim.config/init.lua ~/.config/nvim/init.lua diff --git a/sshd_config b/sshd.ssh.config/sshd_config similarity index 98% rename from sshd_config rename to sshd.ssh.config/sshd_config index 008ef75..65ffcff 100644 --- a/sshd_config +++ b/sshd.ssh.config/sshd_config @@ -35,7 +35,7 @@ PermitRootLogin yes #MaxAuthTries 6 #MaxSessions 10 -PubkeyAuthentication yes +PubkeyAuthentication no # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 # but this is overridden so installations will only check .ssh/authorized_keys @@ -55,7 +55,7 @@ AuthorizedKeysFile .ssh/authorized_keys #IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! -PasswordAuthentication no +PasswordAuthentication yes #PermitEmptyPasswords no # Change to no to disable s/key passwords diff --git a/welcome.sh b/sshd.ssh.config/welcome.sh similarity index 100% rename from welcome.sh rename to sshd.ssh.config/welcome.sh diff --git a/vim.config/init.vim b/vim.config/init.vim new file mode 100644 index 0000000..97b9411 --- /dev/null +++ b/vim.config/init.vim @@ -0,0 +1,296 @@ +" nvim plugins + + " vim-workspace script + if empty(glob('~/.vim/autoload/plug.vim')) + silent execute "!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" + autocmd VimEnter * PlugInstall | source $MYVIMRC + endif + +call plug#begin() +" The default plugin directory will be as follows: +" - Vim (Linux/macOS): '~/.vim/plugged' +" - Vim (Windows): '~/vimfiles/plugged' +" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged' +" You can specify a custom plugin directory by passing it as the argument +" - e.g. `call plug#begin('~/.vim/plugged')` +" - Avoid using standard Vim directory names like 'plugin' + +" Make sure you use single quotes + + " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align + Plug 'junegunn/vim-easy-align' + + " Any valid git URL is allowed + Plug 'https://github.com/junegunn/vim-github-dashboard.git' + + " Multiple Plug commands can be written in a single line using | separators + Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' + + " On-demand loading + Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' } + Plug 'tpope/vim-fireplace', { 'for': 'clojure' } + + " Using a non-default branch + Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } + + " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) + Plug 'fatih/vim-go', { 'tag': '*' } + + " Provides an easy way to browse the tags of the current file and get an overview of its structure + " It does this by creating a sidebar that displays the ctags-generated tags of the current file, ordered by their scope + " This means that for example methods in C++ are displayed under the class they are defined in + " https://vimawesome.com/plugin/tagbar + Plug 'majutsushi/tagbar' + + " Add some css colors + " https://vimawesome.com/plugin/vim-css-color-the-story-of-us + Plug 'ap/vim-css-color' + + " Format code with one button press (or automatically on save). + " https://vimawesome.com/plugin/vim-autoformat + Plug 'chiel92/vim-autoformat' + + " Plugin options + Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } + + " Plugin outside ~/.vim/plugged with post-update hook + Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } + + " Unmanaged plugin (manually installed and updated) + Plug '~/my-prototype-plugin' + + " vim-workspace for create sessions + " https://vimawesome.com/plugin/vim-workspace + Plug 'thaerkh/vim-workspace' + +" Visual Studio Code plugins + + " coloured icons & explorer + " https://github.com/nvim-tree/nvim-tree.lua + Plug 'nvim-tree/nvim-tree.lua' + Plug 'nvim-tree/nvim-web-devicons' + + " you need nerd fonts with special characters, on void you can do something like that: + " ls -la /usr/share/fontconfig/conf.avail + " sudo xbps-reconfigure -f fontconfig + " curl -LO https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/CascadiaCode.zip + " curl -LO https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/Hermit.zip + " mkdir -p ~/.local/share/fonts/Cascadia ~/.local/share/fonts/Hermit + " mv CascadiaCode.zip ~/.local/share/fonts/Cascadia/ + " mv Hermit.zip ~/.local/share/fonts/Hermit + " cd ~/.local/share/fonts/Cascadia && unzip CascadiaCode.zip + " cd ~/.local/share/fonts/Hermit && unzip Hermit.zip + " cd ~ && fc-cache -fv + + " YouCompleteMe a code-completion engine for Vim + " you must install some dependecies manually: + " https://github.com/ycm-core/YouCompleteMe#linux-64-bit + " https://vimawesome.com/plugin/youcompleteme#python-semantic-completion + " Plug 'valloric/youcompleteme' + + " tabline plugin with re-orderable, auto-sizing, clickable tabs, icons, + " nice highlighting, sort-by commands and a magic jump-to-buffer mode + " Plus the tab names are made unique when two filenames match. + " https://github.com/romgrk/barbar.nvim + Plug 'romgrk/barbar.nvim' + + " vscode.nvim (formerly codedark.nvim) is a Lua port of vim-code-dark colorscheme + " for neovim with VScode's light and dark theme + " https://github.com/Mofiqul/vscode.nvim + Plug 'Mofiqul/vscode.nvim' + + " A snazzy buffer line (with tabpage integration) for Neovim built using lua. + " it's need nvim-tree/nvim-web-devicons + " https://github.com/akinsho/bufferline.nvim + " Plug 'ryanoasis/vim-devicons' Icons without colours + Plug 'akinsho/bufferline.nvim', { 'tag': '*' } + + " A Vim plugin which shows a git diff in the sign column. + " https://github.com/airblade/vim-gitgutter + Plug 'airblade/vim-gitgutter' + + " A blazing fast and easy to configure Neovim statusline + " it's need nvim-tree/nvim-web-devicons + " https://github.com/nvim-lualine/lualine.nvim + Plug 'nvim-lualine/lualine.nvim' + + " highly extendable fuzzy finder over lists. + " Built on the latest awesome features from neovim core. + " Telescope is centered around modularity, allowing for easy customization. + " https://github.com/nvim-telescope/telescope.nvim + Plug 'nvim-lua/plenary.nvim' + Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' } + + " The goal of nvim-treesitter is both to provide a simple and easy way + " to use the interface for tree-sitter in Neovim and to provide some + " basic functionality such as highlighting + " https://github.com/nvim-treesitter/nvim-treesitter + Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + + " nvim terminal - toggleterml + " https://github.com/akinsho/toggleterm.nvim + Plug 'akinsho/toggleterm.nvim', {'tag' : '*'} + + " NeoVIM customization section + + " set font for gui + " (if you want the same thing in console - you must change default consolefont) + " (if you use ssh connection you must set nerd fonts on your local machine) + " (windows - https://www.thewindowsclub.com/add-custom-fonts-to-command-prompt) + " for recognize available fonts - use this command: + " fc-list + + au VimEnter * lua vim.opt.guifont='Hurmit NF:style=bold' + + " loading lua scripts + + " toggleterm loading + + au VimEnter * lua require("toggleterm").setup() + + " nvimtree loading + + au VimEnter * lua require("nvim-tree").setup() + + " nvimtree configuration} + " disable netrw at the very start of your init.lua (strongly advised) + au VimEnter * lua vim.g.loaded_netrw = 1 + au VimEnter * lua vim.g.loaded_netrwPlugin = 1 + " set termguicolors to enable highlight groups + au VimEnter * lua vim.opt.termguicolors = true + + " startup + + " display code line numbers by default + set number + + " install plugins automatically + autocmd VimEnter * + \ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) + \| PlugInstall --sync | q + \| endif + + " run neovim with nerd tree automatically + " au VimEnter * NERDTree + + " run nvim-tree automatically + au VimEnter * NvimTreeToggle + + " shortcut mapping + + " insert mode shorcuts + nnoremap :w\|bd + + " set paste shorcut (Ctrl + Shift + V) + " set paste + + " vim panes switching + " map :tabn " Ctrl + l + " map :tabp " Ctrl + h + " map :tabnew " Ctrl + n + + " panes switching (default) + " Ctrl + w w cycle though all windows + " Ctrl + w h takes you left a window + " Ctrl + w j takes you down a window + " Ctrl + w k takes you up a window + " Ctrl + w l takes you right a window + + " NvimTree shortcuts + map :NvimTreeToggle + + " files + + " a - (add) allows the creation of files or folders, creating a folder is done by following the name with the slash /. + " E.g. /nvchad/nvimtree.md will create the related markdown file while /nvchad/nvimtree/ will create the nvimtree + " folder. The creation will occur by default at the location where the cursor is in the file explorer at that time, + " so the selection of the folder where to create the file will have to be done previously or alternatively + " you can write the full path in the statusline, in writing the path you can make use of the auto-complete function + " Ctrl + r - to rename the file regardless of its original name + " d - (delete) to delete the selected file or in case of a folder delete the folder with all its contents + " x - (cut) to cut and copy the selection to the clipboard, can be files or folders with all its contents, + " with this command associated with the paste command you make the file moves within the tree + " c - (copy) like the previous command this copies the file to the clipboard but keeps the original file in its location + " p - (paste) to paste the contents of the clipboard to the current location + " y - to copy only the file name to the clipboard + " Y - to copy the relative path + " g + y - to copy the absolute path + + " opening modes + + " Enter - open as normal without splitting + " Tab - to open the file in a new buffer while keeping the cursor in `nvimtree`, + " this for example is useful if you want to open several files at once + " Ctrl + t - open file in new tab that can be managed separately from the other buffers present + " Ctrl + v - to open the file in the buffer by dividing it vertically into two parts, + " if there was already an open file this will be displayed side by side with the new file + " Ctrl + h - to open the file like the command described above but dividing the buffer horizontally + + " BarBar shortcuts + " https://github.com/romgrk/barbar.nvim + + " Move to previous/next + + nnoremap BufferPrevious + nnoremap BufferNext + + " Re-order to previous/next + nnoremap BufferMovePrevious + nnoremap > BufferMoveNext + + " Goto buffer in position... + nnoremap BufferGoto 1 + nnoremap BufferGoto 2 + nnoremap BufferGoto 3 + nnoremap BufferGoto 4 + nnoremap BufferGoto 5 + nnoremap BufferGoto 6 + nnoremap BufferGoto 7 + nnoremap BufferGoto 8 + nnoremap BufferGoto 9 + nnoremap BufferLast + + " Pin/unpin buffer + nnoremap BufferPin + + " Close buffer + nnoremap BufferClose + " Restore buffer + nnoremap BufferRestore + + " Wipeout buffer + " :BufferWipeout + " Close commands + " :BufferCloseAllButCurrent + " :BufferCloseAllButVisible + " :BufferCloseAllButPinned + " :BufferCloseAllButCurrentOrPinned + " :BufferCloseBuffersLeft + " :BufferCloseBuffersRight + + " Magic buffer-picking mode + nnoremap BufferPick + nnoremap BufferPickDelete + + " Sort automatically by... + nnoremap bb BufferOrderByBufferNumber + nnoremap bd BufferOrderByDirectory + nnoremap bl BufferOrderByLanguage + nnoremap bw BufferOrderByWindowNumber + + " Other: + " :BarbarEnable - enables barbar (enabled by default) + " :BarbarDisable - very bad command, should never be used + + " ToggleTerm shortcuts + + nnoremap exe v:count1 . "ToggleTerm" + inoremap exe v:count1 . "ToggleTerm" + + +" Initialize plugin system +" - Automatically executes `filetype plugin indent on` and `syntax enable`. +call plug#end() +" You can revert the settings after the call like so: +" filetype indent off " Disable file-type-specific indentation +" syntax off " Disable syntax highlighting diff --git a/.zshrc b/zsh.config/.zshrc similarity index 97% rename from .zshrc rename to zsh.config/.zshrc index fc2ba0b..2a7ad9b 100644 --- a/.zshrc +++ b/zsh.config/.zshrc @@ -70,7 +70,7 @@ ZSH_THEME="lambda-00x097" # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -source /root/linux.config/plugins +source /root/linux.config/zsh.config/plugins plugins=(${ZSH_INIT_PLUGINS[@]}) source $ZSH/oh-my-zsh.sh @@ -100,3 +100,5 @@ source $ZSH/oh-my-zsh.sh # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh diff --git a/install.zsh.plugins.sh b/zsh.config/install.zsh.plugins.sh similarity index 66% rename from install.zsh.plugins.sh rename to zsh.config/install.zsh.plugins.sh index ac7bd06..f0655fa 100755 --- a/install.zsh.plugins.sh +++ b/zsh.config/install.zsh.plugins.sh @@ -1,4 +1,4 @@ -source /root/linux.config/plugins +source /root/linux.config/zsh.config/plugins for plugin in ${ZSH_INIT_PLUGINS[@]}; do git clone https://github.com/zsh-users/$plugin.git diff --git a/install.zsh.sh b/zsh.config/install.zsh.sh similarity index 100% rename from install.zsh.sh rename to zsh.config/install.zsh.sh diff --git a/lambda-00x097.zsh-theme b/zsh.config/lambda-00x097.zsh-theme similarity index 100% rename from lambda-00x097.zsh-theme rename to zsh.config/lambda-00x097.zsh-theme diff --git a/plugins b/zsh.config/plugins similarity index 100% rename from plugins rename to zsh.config/plugins