Skip to content

Instantly share code, notes, and snippets.

@mft14
Last active October 12, 2023 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mft14/0d51bcf1638d70deaa0f013861090b19 to your computer and use it in GitHub Desktop.
Save mft14/0d51bcf1638d70deaa0f013861090b19 to your computer and use it in GitHub Desktop.
set history=200
filetype plugin on
filetype indent on
set autoread
au FocusGained,BufEnter * checktime
" Komma Funktionen
let mapleader = ","
map <silent> <leader><cr> :noh<cr> " remove highlight
nnoremap <leader>R :put=range(0,)<Left>
nnoremap <leader>s :%s///gc<Left><Left><Left><Left>
nnoremap <leader>S :%s/\<<C-r><C-w>\>//gc<Left><Left><Left>
" nnoremap <leader>S :'<,'>s///gc<Left><Left><Left><Left>
" ----------
" Perma Vim Macros and MACRO Section " Go within HTML Tags
" let @t ="^f>a"
" Macro = Lists for Markdown for example
let @l ="^i - \<Esc>j"
" Two HTML tabs in a row=? This makro makes a return into them. r = return
let @r ="^f>a\<CR>\<Esc>ko"
" \n at the end, for espanso par exemple
let @n = "$a\\n\<Esc>j"
" ----------
" Unmap Help
map <F1> <Esc>
imap <F1> <Esc>
nnoremap <leader>r :bro ol<CR>
nnoremap <leader>w :set nowrap<CR>
nnoremap <leader>W :set wrap<CR>
nnoremap <leader>q :q <CR>
nnoremap <leader>Q :qa! <CR>
" Marks , better for QWERTZ Layout
nnoremap m '
nnoremap M :mark
nnoremap ` m
nnoremap Y y$
" Save
" map <C-s> :w<CR>
" map <C-a> ggVG
" Jump between HTML tags
nnoremap <C-l> ^%
inoremap <C-j> <Esc>j^%a
" Jump to > , for HTML editing
" nnoremap <C-h> lf>
" Window splits and stuff
" move split panes to left/bottom/top/right
nnoremap <silent> <C-k> :wincmd k<CR>
nnoremap <silent> <C-j> :wincmd j<CR>
nnoremap <silent> <C-h> :wincmd h<CR>
nnoremap <silent> <C-l> :wincmd l<CR>
nnoremap gn <C-w>w
nnoremap gN <C-w>W
nnoremap gH <C-w>t<C-w>K
nnoremap gV <C-w>t<C-w>H
" map <leader>j :split<CR>
map <leader>l :vs<CR>
" Fold Paragraph because I often use
map <leader>z vipzf
" Buffers
nnoremap <silent> gb :bn<CR>
nnoremap <silent> gB :bp<CR>
map <leader>bd :bd<cr>
" Paste end of line EOL
map <C-e> $pj
" CD Bookmarks
map <leader>cd :cd %:p:h<cr>:pwd<cr>
map <leader>pcd :cd ~/Git<cr>
" Going end of line
" map 0 ^
map $ g_
" Center everything when big jumps
" I commented this out because of the smoothie plugin
" nnoremap <C-d> <C-d>zz
" nnoremap <C-u> <C-u>zz
" Shift lines - not working with my other mappings
" nmap <M-j> mz:m+<cr>`z
" nmap <M-k> mz:m-2<cr>`z
" vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
" vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z
" Remember folds https://stackoverflow.com/questions/37552913/vim-how-to-keep-folds-on-save
augroup remember_folds
autocmd!
au BufWinLeave ?* mkview 1
au BufWinEnter ?* silent! loadview 1
augroup END
" System Clipboard
vnoremap <C-c> "+y
map <C-p> "+P
" set so=7
let $LANG='de'
set langmenu=de
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set wildmenu
set wildignore=*.o,*~,*.pyc
set wildignore+=.git\*,.hg\*,.svn\*,*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" Undo = Use persistent history.
"
if !isdirectory("/tmp/.nvim-undo-dir")
call mkdir("/tmp/.nvim-undo-dir", "", 0700)
endif
set undodir=/tmp/.nvim-undo-dir
set undofile
syntax on
set mouse=a
set mouse=v
" Hilfslinien / Visual lines
" set cursorline " Cursor Row Highlight
" set cursorcolumn " Cursor Col Highlight
set cc=90 " cursor colum Abstand
set ttyfast
set termguicolors
set ruler
set cmdheight=1
set hid
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Searching Suche
set ignorecase " Ignore case when searching
set smartcase " When searching try to be smart about cases
set hlsearch " Highlight search results
set incsearch " Makes search act like search in modern browsers
set lazyredraw " Don't redraw while executing macros (good performance config)
set magic " For regular expressions turn magic on
set showmatch " Show matching brackets when text indicator is over them
set autoindent "Indent a new line the same amount
set mat=2
set noerrorbells
set novisualbell
set t_vb=
set tm=500
set number
set relativenumber
set scrolloff=8
set signcolumn=yes
set expandtab
set smarttab
set shiftwidth=4
set tabstop=4
set encoding=utf8
set ffs=unix,dos,mac
" set nobackup
set nowb
set noswapfile
set lbr " Automatical character breaking at 500 chars
set tw=500
set ai "Auto indent
set si "Smart indent
" set wrap "Wrap lines
set nowrap "Unwrap lines
" Statusline still to do
"-----------------------------------
set laststatus=2
set statusline+=CWD:\ %r%{getcwd()}%h\ --\
" set statusline+=\ \ \ \ \ \ \ \
set statusline+=row:\ %l\
set statusline+=col:\ %c\
" set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c
" PLUGINS ----------------------------------------------------------------
" Install the Plugins using this
" curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" webiste = https://www.freecodecamp.org/news/vimrc-configuration-guide-customize-your-vim-editor/
call plug#begin('~/.config/nvim/plugged')
" NORMAL VIM
" Plug 'dense-analysis/ale'
" Plug 'jremmen/vim-ripgrep' "Search text within files (use :Rg) # NOT NEEDED because Telescope Leader fg has it builtin
Plug 'habamax/vim-godot'
Plug 'airblade/vim-gitgutter' " Git
Plug 'francoiscabrol/ranger.vim' " ranger as file manager
Plug 'junegunn/vim-easy-align' " use ga, then the char to align, 2x enter to align center
Plug 'mattn/emmet-vim' " html tags expander
Plug 'mhinz/vim-startify' " Startpage
Plug 'rbgrouleff/bclose.vim' "Don't close window when deleting last buffer
Plug 'tpope/vim-commentary' " uncommenting with gcc
Plug 'tpope/vim-repeat' " required for vim surround action
Plug 'tpope/vim-surround' " surround words, typing dst (tags), yss(, vS{
Plug 'vim-airline/vim-airline' " Status bar
Plug 'vim-airline/vim-airline-themes' " more themes for the status bar
" Vim visual effects
" Plug 'psliwka/vim-smoothie' "Smooth scrolling
Plug 'tribela/vim-transparent' "Add transparency
" NEOVIM
Plug 'ggandor/lightspeed.nvim' " function for f and s/S = searching
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Language Server / Auto completion
Plug 'nvim-lua/plenary.nvim' " All the lua functions I don't want to write twice.
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.1' } " Fuzzy Finder fzf for nvim
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'preservim/nerdtree' " file manager for neovim
" Themes
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
Plug 'ryanoasis/vim-devicons' " For custom icons in the terminal
" Support for programming languages
" Plug 'dart-lang/dart-vim-plugin'
call plug#end()
" Plugin remappings
" ----------------------------------------
nnoremap <space>s :Startify<cr>
let g:user_emmet_leader_key=','
map <leader>rr :Ranger<CR>
" remap ranger key
let g:ranger_map_keys = 0
" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
set guifont=Consolas:h14 " Font Style
" ---------------------------------------- COC Code Completion
" Use tab for trigger completion with characters ahead and navigate
" NOTE: There's always complete item selected b default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
nnoremap <leader>at gaip*|
" coc-explorer
" nmap <space>e <Cmd>CocCommand explorer<CR>
" Use K to show documentation in preview window
nnoremap <silent> K :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
" ---------------------------------------- COC Code Completion END
" ---------------------------------------- Nerdtree
" nnoremap <leader>n :NERDTreeFocus<CR>
" nnoremap <C-n> :NERDTree<CR>
" nnoremap <C-t> :NERDTreeToggle<CR>
" nnoremap <C-f> :NERDTreeFind<CR>
nnoremap <space>e :NERDTreeToggle<CR>
" let NERDTreeMapCloseDir = 'l'
" ---------------------------------------- Neovide
if exists("g:neovide")
set guifont=Monospace:h16
endif
" colorschemes and statusbar line theme
colorscheme tokyonight
let g:airline_theme='tomorrow'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment