Enhanced vim config

This commit is contained in:
Dreaded_X 2022-02-08 03:58:37 +01:00
parent 011ee52d79
commit 4f387fcc6a
Signed by: Dreaded_X
GPG Key ID: 76BDEC4E165D8AD9
3 changed files with 166 additions and 71 deletions

View File

@ -1,3 +1,16 @@
let g:nvim_tree_show_icons = {
\ 'git': 1,
\ 'folders': 1,
\ 'files': 1,
\ 'folder_arrows': 1,
\ }
let g:nvim_tree_icons = {
\ 'default': '',
\ 'folder': {
\ 'arrow_open': "",
\ 'arrow_closed': "",
\ }
\ }
lua require('plugins') lua require('plugins')
" Load vim config in current directory " Load vim config in current directory
@ -10,7 +23,6 @@ let delimitMate_balance_matchpairs = 1
" Theme " Theme
colorscheme gruvbox colorscheme gruvbox
" colorscheme codedark
set t_Co=256 set t_Co=256
set t_ZH= set t_ZH=
set t_ZR= set t_ZR=
@ -35,9 +47,6 @@ endif
let g:airline_symbols.dirty = " ±" let g:airline_symbols.dirty = " ±"
let g:airline_symbols.notexists = " " let g:airline_symbols.notexists = " "
" NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Preferences " Preferences
syntax on syntax on
filetype plugin indent on filetype plugin indent on
@ -53,52 +62,36 @@ set hidden
set updatetime=300 set updatetime=300
set noshowmode set noshowmode
" Keybindings set foldmethod=expr
map <silent> <F2> :NERDTreeToggle<cr> set foldexpr=nvim_treesitter#foldexpr()
map <silent> <M-h> :TmuxNavigateLeft<cr> set foldnestmax=1
map <silent> <M-j> :TmuxNavigateDown<cr> set foldlevel=20
map <silent> <M-k> :TmuxNavigateUp<cr>
map <silent> <M-l> :TmuxNavigateRight<cr>
map <silent> <tab> :bn<cr>
map <silent> <S-tab> :bp<cr>
map <silent> <S-j> 10j
map <silent> <S-k> 10k
map <silent> <C-b> :Bdelete<cr>
map <silent> <F3> :call ToggleQuickfixList()<cr>
map <silent> <F1> :noh<cr>
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" " Keybindings
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" nnoremap <F2> <cmd>NvimTreeToggle<cr>
imap <expr> <BS> pumvisible() ? "\<bs>" : "<Plug>delimitMateBS" nnoremap <M-h> <cmd>TmuxNavigateLeft<cr>
imap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "<Plug>delimitMateCR" nnoremap <M-j> <cmd>TmuxNavigateDown<cr>
nnoremap <M-k> <cmd>TmuxNavigateUp<cr>
nnoremap <M-l> <cmd>TmuxNavigateRight<cr>
nnoremap <tab> <cmd>bn<cr>
nnoremap <S-tab> <cmd>bp<cr>
nnoremap <C-b> <cmd>Bdelete<cr>
nnoremap <F3> <cmd>TroubleToggle workspace_diagnostics<cr>
nnoremap <F4> <cmd>call ToggleQuickfixList()<cr>
nnoremap <F1> <cmd>noh<cr>
nnoremap <S-j> 10j
nnoremap <S-k> 10k
nnoremap <leader>ff <cmd>Telescope find_files<cr> nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr> nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr> nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>lc <cmd>Telescope lsp_code_actions<cr> nnoremap <leader>lc <cmd>Telescope lsp_code_actions<cr>
nnoremap <leader>ls <cmd>Telescope lsp_document_symbols<cr> nnoremap <leader>ls <cmd>Telescope lsp_document_symbols<cr>
map <silent> <leader>ln :lua vim.lsp.diagnostic.goto_next()<cr> nnoremap <leader>ln <cmd>lua vim.lsp.diagnostic.goto_next()<cr>
map <silent> <leader>lp :lua vim.lsp.diagnostic.goto_prev()<cr> nnoremap <leader>lp <cmd>lua vim.lsp.diagnostic.goto_prev()<cr>
map <leader>ll :lua vim.lsp.buf. nnoremap <leader>ll <cmd>lua vim.lsp.buf.
map <silent> <leader>lh :lua vim.lsp.buf.hover()<cr> nnoremap <leader>lh <cmd>lua vim.lsp.buf.hover()<cr>
map <silent> <leader>lf :lua vim.lsp.buf.formatting()<cr> nnoremap <leader>lf <cmd>lua vim.lsp.buf.formatting()<cr>
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.erb,*.jsx,*.tsx" highlight! CmpItemAbbrMatch ctermfg=cyan
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx,*.erb' highlight! CmpItemAbbrMatchFuzzy ctermfg=cyan
" gray
highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
" blue
highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6
highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6
" light blue
highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE
highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE
highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE
" pink
highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0
highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0
" front
highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4

View File

@ -5,6 +5,7 @@ if fn.empty(fn.glob(install_path)) > 0 then
end end
require('packer').startup(function() require('packer').startup(function()
use 'antoinemadec/FixCursorHold.nvim'
use 'wbthomason/packer.nvim' use 'wbthomason/packer.nvim'
use 'gruvbox-community/gruvbox' use 'gruvbox-community/gruvbox'
@ -12,23 +13,27 @@ require('packer').startup(function()
use 'bling/vim-airline' use 'bling/vim-airline'
use 'Raimondi/delimitMate' use 'Raimondi/delimitMate'
use 'alvan/vim-closetag' -- use 'scrooloose/nerdtree'
use 'scrooloose/nerdtree' use {
-- -- use 'tomtom/tcomment_vim' 'kyazdani42/nvim-tree.lua',
requires = {
'kyazdani42/nvim-web-devicons', -- optional, for file icon
},
config = function() require'nvim-tree'.setup {
auto_close = true,
} end
}
use 'tpope/vim-commentary' use 'tpope/vim-commentary'
use 'tpope/vim-surround' use 'tpope/vim-surround'
use 'christoomey/vim-tmux-navigator' use 'christoomey/vim-tmux-navigator'
use 'tpope/vim-dispatch' use 'tpope/vim-dispatch'
use 'milkypostman/vim-togglelist' use 'milkypostman/vim-togglelist'
use 'moll/vim-bbye' use 'moll/vim-bbye'
-- use { 'junegunn/fzf', run = './install --bin' }
-- use 'junegunn/fzf.vim'
-- use 'tpope/vim-fugitive'
-- use 'ConradIrwin/vim-bracketed-paste'
use { use {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
requires = { {'nvim-lua/plenary.nvim'} } requires = { {'nvim-lua/plenary.nvim'} }
} }
use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }
use 'neovim/nvim-lspconfig' use 'neovim/nvim-lspconfig'
use 'hrsh7th/cmp-nvim-lsp' use 'hrsh7th/cmp-nvim-lsp'
@ -37,6 +42,26 @@ require('packer').startup(function()
use 'hrsh7th/cmp-cmdline' use 'hrsh7th/cmp-cmdline'
use 'hrsh7th/nvim-cmp' use 'hrsh7th/nvim-cmp'
use 'onsails/lspkind-nvim' use 'onsails/lspkind-nvim'
use 'ray-x/lsp_signature.nvim'
use {
"folke/trouble.nvim",
requires = "kyazdani42/nvim-web-devicons",
config = function()
require("trouble").setup {
signs = {
-- icons / text used for a diagnostic
error = "error",
warning = "warn",
hint = "hint",
information = "info"
},
}
end
}
use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }
use 'windwp/nvim-ts-autotag'
use 'JoosepAlviste/nvim-ts-context-commentstring'
use 'hrsh7th/cmp-vsnip' use 'hrsh7th/cmp-vsnip'
use 'hrsh7th/vim-vsnip' use 'hrsh7th/vim-vsnip'
@ -50,7 +75,30 @@ end)
vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true }) vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true })
vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true }) vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true })
require('telescope').setup{ defaults = { file_ignore_patterns = { "node_module" } } } require('telescope').setup {
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
-- the default case_mode is "smart_case"
}
}
}
-- To get fzf loaded and working with telescope, you need to call
-- load_extension, somewhere after setup function:
require('telescope').load_extension('fzf')
require "lsp_signature".setup({
hint_enable = false,
handler_opts = {
border = "none" -- double, rounded, single, shadow, none
},
padding = ' ',
})
require'nvim-tree'.setup()
-- nvim-cmp setup -- nvim-cmp setup
local cmp = require 'cmp' local cmp = require 'cmp'
@ -145,7 +193,7 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
} }
) )
vim.o.updatetime = 250 vim.o.updatetime = 100
-- Taken from: https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/lsp.lua -- Taken from: https://github.com/wookayin/dotfiles/blob/master/nvim/lua/config/lsp.lua
-- Makes it so the diagnostic popup does not keep overwriting other popups -- Makes it so the diagnostic popup does not keep overwriting other popups
@ -178,8 +226,6 @@ augroup LSPDiagnosticsOnHover
augroup END augroup END
]] ]]
vim.cmd [[autocmd CursorHoldI * silent! lua vim.lsp.buf.signature_help()]]
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp -- Enable some language servers with the additional completion capabilities offered by nvim-cmp
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
@ -217,10 +263,21 @@ cmp.setup {
} }
} }
vim.fn.sign_define("LspDiagnosticsSignError", { text="" }) require'nvim-treesitter.configs'.setup {
vim.fn.sign_define("LspDiagnosticsSignWarning", { text="" }) ensure_installed = "maintained",
vim.fn.sign_define("LspDiagnosticsSignInformation", { text="" }) }
vim.fn.sign_define("LspDiagnosticsSignHint", { text="" }) require('nvim-ts-autotag').setup()
require'nvim-treesitter.configs'.setup {
context_commentstring = {
enable = true
}
}
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- Set completeopt to have a better completion experience -- Set completeopt to have a better completion experience
vim.o.completeopt = 'menuone,noselect' -- vim.o.completeopt = 'menuone,noselect'

View File

@ -69,6 +69,11 @@ end
time([[try_loadstring definition]], false) time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true) time([[Defining packer_plugins]], true)
_G.packer_plugins = { _G.packer_plugins = {
["FixCursorHold.nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim",
url = "https://github.com/antoinemadec/FixCursorHold.nvim"
},
["cmp-buffer"] = { ["cmp-buffer"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-buffer", path = "/home/tim/.local/share/nvim/site/pack/packer/start/cmp-buffer",
@ -109,16 +114,16 @@ _G.packer_plugins = {
path = "/home/tim/.local/share/nvim/site/pack/packer/start/gruvbox", path = "/home/tim/.local/share/nvim/site/pack/packer/start/gruvbox",
url = "https://github.com/gruvbox-community/gruvbox" url = "https://github.com/gruvbox-community/gruvbox"
}, },
["lsp_signature.nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/lsp_signature.nvim",
url = "https://github.com/ray-x/lsp_signature.nvim"
},
["lspkind-nvim"] = { ["lspkind-nvim"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/lspkind-nvim", path = "/home/tim/.local/share/nvim/site/pack/packer/start/lspkind-nvim",
url = "https://github.com/onsails/lspkind-nvim" url = "https://github.com/onsails/lspkind-nvim"
}, },
nerdtree = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nerdtree",
url = "https://github.com/scrooloose/nerdtree"
},
["nvim-cmp"] = { ["nvim-cmp"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-cmp", path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-cmp",
@ -129,6 +134,32 @@ _G.packer_plugins = {
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
url = "https://github.com/neovim/nvim-lspconfig" url = "https://github.com/neovim/nvim-lspconfig"
}, },
["nvim-tree.lua"] = {
config = { "\27LJ\1\2J\0\0\2\0\4\0\a4\0\0\0%\1\1\0>\0\2\0027\0\2\0003\1\3\0>\0\2\1G\0\1\0\1\0\1\15auto_close\2\nsetup\14nvim-tree\frequire\0" },
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-tree.lua",
url = "https://github.com/kyazdani42/nvim-tree.lua"
},
["nvim-treesitter"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-treesitter",
url = "https://github.com/nvim-treesitter/nvim-treesitter"
},
["nvim-ts-autotag"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-ts-autotag",
url = "https://github.com/windwp/nvim-ts-autotag"
},
["nvim-ts-context-commentstring"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-ts-context-commentstring",
url = "https://github.com/JoosepAlviste/nvim-ts-context-commentstring"
},
["nvim-web-devicons"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/nvim-web-devicons",
url = "https://github.com/kyazdani42/nvim-web-devicons"
},
["packer.nvim"] = { ["packer.nvim"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/packer.nvim", path = "/home/tim/.local/share/nvim/site/pack/packer/start/packer.nvim",
@ -139,11 +170,22 @@ _G.packer_plugins = {
path = "/home/tim/.local/share/nvim/site/pack/packer/start/plenary.nvim", path = "/home/tim/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim" url = "https://github.com/nvim-lua/plenary.nvim"
}, },
["telescope-fzf-native.nvim"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope-fzf-native.nvim",
url = "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
},
["telescope.nvim"] = { ["telescope.nvim"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope.nvim", path = "/home/tim/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim" url = "https://github.com/nvim-telescope/telescope.nvim"
}, },
["trouble.nvim"] = {
config = { "\27LJ\1\2<EFBFBD>\1\0\0\3\0\6\0\t4\0\0\0%\1\1\0>\0\2\0027\0\2\0003\1\4\0003\2\3\0:\2\5\1>\0\2\1G\0\1\0\nsigns\1\0\0\1\0\4\16information\tinfo\thint\thint\fwarning\twarn\nerror\nerror\nsetup\ftrouble\frequire\0" },
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/trouble.nvim",
url = "https://github.com/folke/trouble.nvim"
},
["typescript-vim"] = { ["typescript-vim"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/typescript-vim", path = "/home/tim/.local/share/nvim/site/pack/packer/start/typescript-vim",
@ -159,11 +201,6 @@ _G.packer_plugins = {
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-bbye", path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-bbye",
url = "https://github.com/moll/vim-bbye" url = "https://github.com/moll/vim-bbye"
}, },
["vim-closetag"] = {
loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-closetag",
url = "https://github.com/alvan/vim-closetag"
},
["vim-code-dark"] = { ["vim-code-dark"] = {
loaded = true, loaded = true,
path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-code-dark", path = "/home/tim/.local/share/nvim/site/pack/packer/start/vim-code-dark",
@ -207,6 +244,14 @@ _G.packer_plugins = {
} }
time([[Defining packer_plugins]], false) time([[Defining packer_plugins]], false)
-- Config for: nvim-tree.lua
time([[Config for nvim-tree.lua]], true)
try_loadstring("\27LJ\1\2J\0\0\2\0\4\0\a4\0\0\0%\1\1\0>\0\2\0027\0\2\0003\1\3\0>\0\2\1G\0\1\0\1\0\1\15auto_close\2\nsetup\14nvim-tree\frequire\0", "config", "nvim-tree.lua")
time([[Config for nvim-tree.lua]], false)
-- Config for: trouble.nvim
time([[Config for trouble.nvim]], true)
try_loadstring("\27LJ\1\2<EFBFBD>\1\0\0\3\0\6\0\t4\0\0\0%\1\1\0>\0\2\0027\0\2\0003\1\4\0003\2\3\0:\2\5\1>\0\2\1G\0\1\0\nsigns\1\0\0\1\0\4\16information\tinfo\thint\thint\fwarning\twarn\nerror\nerror\nsetup\ftrouble\frequire\0", "config", "trouble.nvim")
time([[Config for trouble.nvim]], false)
if should_profile then save_profiles() end if should_profile then save_profiles() end
end) end)