Added new neovim config

This commit is contained in:
Jef Roosens 2021-09-22 12:18:25 +02:00
parent b5873bffae
commit cef1d397f8
Signed by: Jef Roosens
GPG key ID: B580B976584B5F30
35 changed files with 470 additions and 3427 deletions

59
.config/nvim/lua/keys.lua Normal file
View file

@ -0,0 +1,59 @@
imap("jk", "<Esc>")
imap("<Esc>", "<nop>")
-- Navigate splits
nmap("<leader>h", ":wincmd h<CR>")
nmap("<leader>j", ":wincmd j<CR>")
nmap("<leader>k", ":wincmd k<CR>")
nmap("<leader>l", ":wincmd l<CR>")
-- Just some laziness
nmap("<leader>w", ":w<CR>")
nmap("<leader>q", ":q<CR>")
-- As I don't use arrow keys for navigation, I use them for resizing
nmap("<Up>", ":resize +5<CR>")
nmap("<Down>", ":resize -5<CR>")
nmap("<Right>", ":vertical resize +5<CR>")
nmap("<Left>", ":vertical resize -5<CR>")
nmap("<S-Up>", ":resize +1<CR>")
nmap("<S-Down>", ":resize -1<CR>")
nmap("<S-Right>", ":vertical resize +1<CR>")
nmap("<S-Left>", ":vertical resize -1<CR>")
-- Disable arrow keys in editing & visual mode, as I have no need for them
imap("<Up>", "<nop>")
imap("<Down>", "<nop>")
imap("<Left>", "<nop>")
imap("<Right>", "<nop>")
vmap("<Up>", "<nop>")
vmap("<Down>", "<nop>")
vmap("<Left>", "<nop>")
vmap("<Right>", "<nop>")
-- These bindings I use for managing tabs
nmap("<leader>ee", ":$tabnew<CR>")
nmap("<leader>eL", ":tabnew<CR>")
nmap("<leader>eH", ":-tabnew<CR>")
nmap("<leader>ed", ":tabclose<CR>")
nmap("<leader>el", ":tabnext<CR>")
nmap("<leader>eh", ":tabprevious<CR>")
nmap("<leader>er", ":tabnew<CR>:e term://$SHELL<CR>i")
-- TODO add config editing keybinds
nmap("<leader>a", "<C-^>")
tmap("jk", "<C-\\><C-n>")
-- nmap("<leader>rr", ":e term://$SHELL<CR>")
-- nmap("<leader>rh", ":vsp<CR>:wincmd h<CR>:e term://$SHELL<CR>")
-- nmap("<leader>rl", ":vsp<CR>:e term://$SHELL<CR>")
-- nmap("<leader>rk", ":sp<CR>:wincmd k<CR>:e term://$SHELL<CR>")
-- nmap("<leader>rj", ":sp<CR>:e term://$SHELL<CR>")
nmap("<leader>fh", ":vsp<CR>:wincmd h<CR>")
nmap("<leader>fj", ":sp<CR>")
nmap("<leader>fk", ":sp<CR>:wincmd k<CR>")
nmap("<leader>fl", ":vsp<CR>")
vim.api.nvim_set_keymap("n", "gb", "<C-o>", {})

View file

@ -0,0 +1,169 @@
require("impatient")
-- This part auto-installs Packer if it's not present
-- Largely inspired by https://github.com/wbthomason/packer.nvim#bootstrapping
local fn = vim.fn
local g = vim.g
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.api.nvim_command('packadd packer.nvim')
end
require('packer').startup(function()
use "wbthomason/packer.nvim"
-- Improves boot times
-- use {"lewis6991/impatient.nvim", rocks = 'mpack'}
use "ctrlpvim/ctrlp.vim"
use "tpope/vim-fugitive"
use "tpope/vim-commentary"
use "tpope/vim-surround"
use "majutsushi/tagbar"
use "airblade/vim-gitgutter"
use "hynek/vim-python-pep8-indent"
use "michaeljsmith/vim-indent-object"
use "preservim/nerdtree"
use "cespare/vim-toml"
use "jiangmiao/auto-pairs"
use "godlygeek/tabular"
use "editorconfig/editorconfig-vim"
use "neovim/nvim-lspconfig"
-- use "hrsh7th/nvim-compe"
use "marko-cerovac/material.nvim"
use "nvim-lua/completion-nvim"
use "steelsojka/completion-buffers"
use {"nvim-treesitter/nvim-treesitter", run=":TSUpdate"}
use "akinsho/nvim-toggleterm.lua"
end)
-- =====PLUGIN CONFIGS=====
-- ctrlpvim/ctrlp.vim
g.ctrlp_map = "<leader>t"
g.ctrlp_use_caching = 1
g.ctrlp_clear_cache_on_exit = 0
g.ctrlp_cache_dir = "./.vim/cache/ctrlp"
g.ctrlp_user_command = {
'.git', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'
}
--Limit max number of files
--This prevents me from indexing my entire HOME by accident
g.ctrlp_max_files = 10000
--Also limit recursion depth
g.ctrlp_max_depth = 40
-- tpope/vim-fugitive
nmap("<leader>gg", ":Git<CR>")
nmap("<leader>gc", ":Git commit<CR>")
nmap("<leader>gp", ":Git push<CR>")
nmap("<leader>gd", ":Gdiffsplit!<CR>")
nmap("<leader>gm", ":Git mergetool<CR>")
nmap("<leader>gb", ":Git blame<CR>")
-- airblade/vim-gitgutter
g.gitgutter_map_keys = 0
-- indentline
g.indentLine_char_list = {'|', '¦', '', ''}
-- preservim/nerdtree
g.NERDTreeIgnore = {
'^\\.vim$[[dir]]',
'^\\.vscode$[[dir]]', '.*\\.code-workspace$[[file]]', '^\\.idea$[[dir]]',
'^__pycache__$[[dir]]', '^\\.pytest_cache$[[dir]]', '^venv$[[dir]]',
'\\.egg-info$[[dir]]', '^dist$[[dir]]', '^build$[[dir]]',
'^\\.eggs$[[dir]]',
'^out$[[dir]]',
'^\\.git$[[dir]]',
'^\\.stack-work$[[dir]]', '\\.lock$',
'^CMakeFiles$[[dir]]', '^CMakeCache.txt$[[file]]',
'.pdf$[[file]]'
}
g.NERDTreeShowHidden = 1
g.NERDTreeMinimalUI = 1
g.NERDTreeDirArrows = 1
g.NERDTreeQuitOnOpen = 1
g.NERDTreeChDirMode = 0
g.NERDTreeNaturalSort = 1
g.NERDTreeShowFiles = 1
g.NERDTreeShowLineNumbers = 0
g.NERDTreeWinPos = 'left'
g.NERDTreeMinimalMenu = 1
g.NERDTreeAutoDeleteBuffer = 1
nmap("tt", ":NERDTreeFind<CR>")
-- majutsushi/tagbar
g.tagbar_map_nexttag = "J"
g.tagbar_map_prevtag = "K"
g.tagbar_map_showproto = "u"
g.tagbar_sort = 0
g.tagbar_compact = 1
g.tagbar_autoshowtag = 1
g.no_status_line = 1
g.tagbar_autoclose = 1
nmap("tr", ":TagbarToggle<CR>")
-- neovim/neovim-lspconfig
-- Comes with clang
require'lspconfig'.clangd.setup{}
-- NPM: dockerfile-language-server-nodejs
require'lspconfig'.dockerls.setup{}
-- Pacman: haskell-language-server
-- AUR: haskell-language-server-bin
-- GH: https://github.com/haskell/haskell-language-server
require'lspconfig'.hls.setup{}
-- Pacman: rust-analyzer
-- GH: https://github.com/rust-analyzer/rust-analyzer
require'lspconfig'.rust_analyzer.setup{}
-- material
require('material').set()
nmap("<leader>c", [[<Cmd>lua require('material.functions').toggle_style()<CR>]])
-- nvim-lua/completion-nvim
vim.api.nvim_exec("autocmd BufEnter * lua require'completion'.on_attach()", false)
--Use <Tab> and <S-Tab> to navigate through popup menu
vim.api.nvim_set_keymap("i", "<Tab>", 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {
expr = true
})
vim.api.nvim_set_keymap("i", "<S-Tab>", 'pumvisible() ? "\\<C-p>" : "\\<S-Tab>"', {
expr = true
})
--Set completeopt to have a better completion experience
vim.o.completeopt = "menuone,noinsert,noselect"
--Avoid showing message extra message when using completion
vim.o.shortmess = vim.o.shortmess .. "c"
vim.g.completion_chain_complete_list = {
default = {
{ complete_items = { 'lsp', "buffer", "buffers" } },
{ mode = { '<c-p>' } },
{ mode = { '<c-n>' } }
},
}
require"nvim-treesitter.configs".setup {
highlight = { enable = true }
}
vim.o.hidden = true
require("toggleterm").setup {
-- open_mapping = "<leader>r",
direction = "float",
insert_mappings = false,
start_in_insert = false
}
nmap("<leader>rr", ":ToggleTerm<CR>")
nmap("<leader>ry", ":1ToggleTerm<CR>")
nmap("<leader>ru", ":2ToggleTerm<CR>")
nmap("<leader>ri", ":3ToggleTerm<CR>")
nmap("<leader>ro", ":4ToggleTerm<CR>")
nmap("<leader>rp", ":5ToggleTerm<CR>")

View file

@ -0,0 +1,54 @@
local o = vim.o
local g = vim.g
g.mapleader = " "
g.maplocalleader = "\\<tab>"
-- I often use non-standard shells that don't play nicely wiht certain features
o.shell = "/bin/bash"
-- Centers your cursor whenever possible
-- 999 is just a really large number (I think it's amount of lines or something)
o.scrolloff = 999
-- Forces Neovim to assume a 256-color terminal; required for certain colorschemes
o.termguicolors = true
-- Set the colorscheme
-- g.colors_name = "flattened_dark"
-- This combo shows the absolute line number on the current line & the relative one on all the others
o.number = true
o.relativenumber = true
-- Opens new files to the bottom, right resp. of the current buffer
o.splitbelow = true
o.splitright = true
-- Converts tabs to 4 spaces
o.expandtab = true
o.tabstop = 4
o.shiftwidth = 4
-- Show search matches as I'm typing
o.incsearch = true
-- Makes search case-sensitive only when using caps
o.smartcase = true
-- Don't highlight search results after search is finished
o.hlsearch = false
-- Create swap files
o.swapfile = true
-- Where to store the swap files; I store mine in the current directory
o.directory = "./.vim/swap//"
o.backup = false
o.undofile = true
o.undodir = "./.vim/undo//"
o.updatetime = 250
o.shelltemp = false
-- o.completeopt = "menuone,noselect"

View file

@ -0,0 +1,11 @@
function map(mode, keys, command)
vim.api.nvim_set_keymap(mode, keys, command, {
silent = true,
noremap = true
})
end
nmap = function(keys, command) map("n", keys, command) end
imap = function(keys, command) map("i", keys, command) end
vmap = function(keys, command) map("v", keys, command) end
tmap = function(keys, command) map("t", keys, command) end