Skip to content

Instantly share code, notes, and snippets.

@CodeSigils
Last active February 14, 2024 17:17
Show Gist options
  • Save CodeSigils/c863b6f8ca051d33952471ce33072cfb to your computer and use it in GitHub Desktop.
Save CodeSigils/c863b6f8ca051d33952471ce33072cfb to your computer and use it in GitHub Desktop.
neovim setup
" >> load plugins
call plug#begin(stdpath('data') . 'vimplug')
" Telescope requirements...
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-lua/popup.nvim'
Plug 'nvim-telescope/telescope.nvim'
" Telescope
Plug 'nvim-telescope/telescope-fzy-native.nvim', {'do': 'make'}
" Fzf
"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Telescope File browser
Plug 'nvim-telescope/telescope-file-browser.nvim'
" Treesitter
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
" line - icons
Plug 'glepnir/galaxyline.nvim', { 'branch': 'main' }
Plug 'kyazdani42/nvim-web-devicons' " needed for galaxyline icons
" Themes
Plug 'NLKNguyen/papercolor-theme', {'as': 'paper'}
Plug 'gruvbox-community/gruvbox'
Plug 'flazz/vim-colorschemes'
Plug 'chriskempson/base16-vim'
" Terminal
Plug 'nikvdp/neomux'
" Helpers
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'junegunn/gv.vim'
Plug 'mbbill/undotree'
Plug 'theprimeagen/vim-be-good'
Plug 'tpope/vim-projectionist'
Plug 'tomlion/vim-solidity'
Plug 'tpope/vim-eunuch'
" Grammar checking
Plug 'rhysd/vim-grammarous'
" Nvim motions
Plug 'phaazon/hop.nvim'
" Magit
Plug 'TimUntersberger/neogit'
" Git diff
Plug 'sindrets/diffview.nvim'
" Native LSP
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer', { 'branch': 'main' }
" Autocomplete
Plug 'hrsh7th/nvim-compe'
" LSP autocomplete
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'L3MON4D3/LuaSnip'
Plug 'saadparwaiz1/cmp_luasnip'
"debugging
Plug 'mfussenegger/nvim-dap'
Plug 'leoluz/nvim-dap-go'
Plug 'rcarriga/nvim-dap-ui'
Plug 'theHamsta/nvim-dap-virtual-text'
Plug 'nvim-telescope/telescope-dap.nvim'
" Comments
Plug 'tomtom/tcomment_vim'
Plug 'folke/todo-comments.nvim'
" Rfc
Plug 'mhinz/vim-rfc'
"Markdown preview
Plug 'ellisonleao/glow.nvim'
"Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }}
"Language packs
Plug 'sheerun/vim-polyglot'
Plug 'tpope/vim-ragtag'
" Format
Plug 'sbdchd/neoformat'
" Rust
Plug 'rust-lang/rust.vim'
" Go
Plug 'darrikonn/vim-gofmt'
" Frontend
Plug 'pangloss/vim-javascript' "JS support
Plug 'leafgarland/typescript-vim' "TS support
Plug 'maxmellon/vim-jsx-pretty' "JS and JSX syntax
Plug 'jparise/vim-graphql' "GraphQL syntax
Plug 'mattn/emmet-vim'
call plug#end()
" basic settings
set nocompatible
colorscheme PaperColor
syntax on
set number
set hidden
set relativenumber
set ignorecase " ignore case
set smartcase " but don't ignore it, when search string contains uppercase letters
set incsearch " do incremental searching
set hlsearch
set visualbell
set expandtab
set tabstop=4
set shiftwidth=4
set ruler
set spell
set title
set list
set listchars=tab:-\ ,trail:.
set wildmode=longest:full,full
set wildmenu
set nojoinspaces
set smartindent
set autoindent
set virtualedit=all
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set mouse=a " mouse support
set clipboard=unnamedplus " system 's cliboard integration
set scrolloff=4
set sidescrolloff=4
set splitright
set nowrap
set exrc
set updatetime=300
" Hide Error highlighting
au ColorScheme * hi Error NONE
au ColorScheme * hi ErrorMsg NONE
au GuiEnter * hi Error NONE
au GuiEnter * hi ErrorMsg NONE
" Ripgrep
if executable('rg')
let g:rg_derive_root='true'
endif
set encoding=UTF-8
let loaded_matchparen = 1
let mapleader = "\<space>"
" Fix crazy vim defaults
nnoremap Y y$
nnoremap n nzzv
nnoremap N Nzzzv
nnoremap J mzJ`z
inoremap , ,<C-g>u
inoremap . .<C-g>u
inoremap ! !<C-g>u
inoremap ? ?<C-g>u
" edit/source vim settings
nmap <leader>ve :e ~/.config/nvim/init.vim
nnoremap <Leader>rv <CR> :so ~/.config/nvim/init.vim<CR>
" Jumplist mutations
nnoremap <expr> k (v:count > 5 ? "m'" . v:count : "") . 'k'
nnoremap <expr> j (v:count > 5 ? "m'" . v:count : "") . 'j'
" Moving text
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" greatest remap ever
xnoremap <leader>p "_dP
" next greatest remap ever : asbjornHaland
nnoremap <leader>y "+y
vnoremap <leader>y "+y
nnoremap <leader>Y gg"+yG
nnoremap <leader>d "_d
vnoremap <leader>d "_d
inoremap <C-j> <esc>:m .+1<CR>==
inoremap <C-k> <esc>:m .-2<CR>==
nnoremap <leader>j :m .+1<CR>==
nnoremap <leader>k :m .-2<CR>==
" zoom
nnoremap <Leader>+ :vertical resize +5<CR>
nnoremap <Leader>- :vertical resize -5<CR>
nnoremap <Leader>rp :resize 100<CR>
" Navigate buffers
nnoremap <leader>bn :bnext<CR>
nnoremap <leader>bp :bprevious<CR>
nnoremap <leader>bf :bfirst<CR>
nnoremap <leader>bl :blast<CR>
" = Telescope bindings
nnoremap <leader>ne <cmd>lua require "telescope".extensions.file_browser.file_browser{}<cr>
nnoremap <Leader>pp <cmd>lua require'telescope.builtin'.builtin{}<CR>
" most recently used files
nnoremap <Leader>m <cmd>lua require'telescope.builtin'.oldfiles{}<CR>
" find buffer
nnoremap <Leader>; <cmd>lua require'telescope.builtin'.buffers{}<CR>
" find in current buffer - ivy can open position in split view with Ctrl-v
nnoremap <Leader>/ <cmd>lua require'telescope.builtin'.current_buffer_fuzzy_find{require('telescope.themes').ivy}<CR>
" nnoremap <Leader>/ <cmd>lua require'telescope.builtin'.current_buffer_fuzzy_find{ sorting_strategy="ascending", prompt_position="top" }<CR>
" nnoremap <Leader>/ :Telescope current_buffer_fuzzy_find sorting_strategy=ascending <CR>
" bookmarks
nnoremap <Leader>' <cmd>lua require'telescope.builtin'.marks{}<CR>
" git files
nnoremap <Leader>f <cmd>lua require'telescope.builtin'.git_files{}<CR>
" all files
nnoremap <Leader>bfs <cmd>lua require'telescope.builtin'.find_files{}<CR>
" ripgrep like grep through dir
nnoremap <Leader>rg <cmd>lua require'telescope.builtin'.live_grep{}<CR>
" pick color scheme
nnoremap <Leader>cs <cmd>lua require'telescope.builtin'.colorscheme{}<CR>
" >> setup nerdcomment key bindings
"let g:NERDCreateDefaultMappings = 0
"let g:NERDSpaceDelims = 1
xnoremap <Leader>ci <cmd>call NERDComment('n', 'toggle')<CR>
nnoremap <Leader>ci <cmd>call NERDComment('n', 'toggle')<CR>
" >> Lsp key bindings
nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> <C-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> K <cmd>Lspsaga hover_doc<CR>
nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> <C-p> <cmd>Lspsaga diagnostic_jump_prev<CR>
nnoremap <silent> <C-n> <cmd>Lspsaga diagnostic_jump_next<CR>
nnoremap <silent> bf <cmd>lua vim.lsp.buf.format{async=true}<CR>
nnoremap <silent> bn <cmd>lua vim.lsp.buf.rename()<CR>
nnoremap <silent> ba <cmd>Lspsaga code_action<CR>
xnoremap <silent> ba <cmd>Lspsaga range_code_action<CR>
nnoremap <silent> bs <cmd>Lspsaga signature_help<CR>
" ~/.config/nvim/lua/lsp.lua
" ~/.config/nvim/lua/treesitter.lua
" ~/.config/nvim/lua/statusbar.lua
" ~/.config/nvim/lua/completion.lua
lua <<EOF
require("lsp")
require("treesitter")
require("statusbar")
require("completion")
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment