dotfiles/dot_config/nvim/init.lua

258 lines
7.1 KiB
Lua
Raw Normal View History

2023-02-11 14:11:00 +01:00
HOME = os.getenv("HOME")
vim.cmd([[colorscheme gruvbox]])
vim.g.mapleader = " "
vim.g.maplocalleader = '\\'
-- Plugins
require "paq" {
"savq/paq-nvim";
{"nvim-treesitter/nvim-treesitter", run=function() vim.cmd "TSUpdate" end};
"nvim-treesitter/nvim-treesitter-textobjects";
"nvim-tree/nvim-web-devicons";
"onsails/lspkind.nvim";
"VonHeikemen/lsp-zero.nvim";
-- LSP support
"lukas-reineke/lsp-format.nvim";
"neovim/nvim-lspconfig";
"williamboman/mason.nvim";
"williamboman/mason-lspconfig.nvim";
-- Autocomplete
"hrsh7th/nvim-cmp";
"hrsh7th/cmp-buffer";
"hrsh7th/cmp-path";
"saadparwaiz1/cmp_luasnip";
"hrsh7th/cmp-nvim-lsp";
"hrsh7th/cmp-nvim-lua";
-- Snippets
"L3MON4D3/LuaSnip";
"rafamadriz/friendly-snippets";
"kylechui/nvim-surround";
"windwp/nvim-autopairs";
"numToStr/Comment.nvim";
{"phaazon/hop.nvim", branch="v2"};
"nvim-lua/plenary.nvim";
-- Fuzzy search
{"nvim-telescope/telescope-fzf-native.nvim", run="gmake"};
"nvim-telescope/telescope-file-browser.nvim";
"nvim-telescope/telescope.nvim";
"mfussenegger/nvim-dap";
"rcarriga/nvim-dap-ui";
"lewis6991/gitsigns.nvim";
-- "ray-x/go.nvim";
"renerocksai/telekasten.nvim";
"renerocksai/calendar-vim";
"nvim-lualine/lualine.nvim";
"ellisonleao/gruvbox.nvim";
}
require('nvim-web-devicons').setup {}
require('lsp-format').setup {}
require('nvim-autopairs').setup()
require('nvim-surround').setup()
require('Comment').setup()
require('hop').setup()
require('dapui').setup()
require('gitsigns').setup()
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = '|',
section_separators = '',
}
}
require("gruvbox").setup {
italic = false,
contrast = "hard"
}
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimport()
end,
group = format_sync_grp,
})
-- Options
local o = vim.opt
-- basic settings
o.encoding = "utf-8"
o.backspace = "indent,eol,start" -- backspace works on every char in insert mode
o.completeopt = 'menu,menuone,noselect'
o.history = 1000
o.dictionary = '/usr/share/dict/words'
o.startofline = true
o.title = true
o.clipboard='unnamedplus'
-- Mapping waiting time
o.timeoutlen = 200
o.ttimeoutlen = 0
-- Spellchecker
o.spelllang="en_us"
o.spellfile= HOME .. '/.vim/spell/en.utf8.add'
o.thesaurus= HOME .. '/.vim/thesaurus/english.txt'
-- Display
o.showmatch = true -- show matching brackets
o.colorcolumn = '90'
o.cursorline = true
o.scrolloff = 8 -- always show 3 rows from edge of the screen
o.splitbelow = true
o.splitright = true
o.virtualedit = 'block'
o.synmaxcol = 300 -- stop syntax highlight after x lines for performance
o.laststatus = 2 -- always show status line
o.list = false -- do not display white characters
o.termguicolors = true
o.background = "dark"
-- o.updatetime = 100
vim.cmd([[highlight SpellBad cterm=undercurl ctermfg=Red]])
-- Folding
o.foldenable = false
o.foldlevel = 4 -- limit folding to 4 levels
o.foldmethod = 'syntax' -- use language syntax to generate folds
o.wrap = false --do not wrap lines even if very long
o.eol = false -- show if there's no eol char
o.showbreak= '' -- character to show when line is broken
-- Sidebar
o.number = true -- line number on the left
o.relativenumber = true
o.numberwidth = 3 -- always reserve 3 spaces for line number
o.signcolumn = 'yes' -- keep 1 column for coc.vim check
o.modelines = 0
-- Bottombar
o.showcmd = true -- display command in bottom bar
o.ruler = false
o.showmode = false
-- Search
o.incsearch = true -- starts searching as soon as typing, without enter needed
o.hlsearch = true -- highlighting of search matches
o.ignorecase = true -- ignore letter case when searching
o.smartcase = true -- case insentive unless capitals used in search
o.wildignorecase = true
o.matchtime = 2 -- delay before showing matching paren
o.mps = vim.o.mps .. ",<:>"
-- White characters
o.smartindent = true
o.breakindent = true
o.tabstop = 4
o.shiftwidth = 4 -- indentation rule
o.softtabstop = 4
o.expandtab = true -- expand tab to spaces
o.smarttab = true
-- Shortmess
o.shortmess = o.shortmess
+ {
A = true, -- don't give the "ATTENTION" message when an existing swap file is found.
I = true, -- don't give the intro message when starting Vim |:intro|.
W = true, -- don't give "written" or "[w]" when writing a file
c = true, -- don't give |ins-completion-menu| messages
m = true, -- use "[+]" instead of "[Modified]"
}
-- Format options
o.formatoptions = o.formatoptions
+ {
c = false,
o = false, -- O and o, don't continue comments
r = true, -- Pressing Enter will continue comments
}
-- Backup files
o.hidden = true
o.autowrite = true
o.autoread = true
o.backup = true -- use backup files
o.writebackup = false
o.swapfile = false -- do not use swap file
o.undofile = true
o.undodir = HOME .. '/.vim/dirs/undo//' -- undo files
o.backupdir = HOME .. '/.vim/dirs/backup//' -- backups
-- Commands mode
o.wildmenu = true -- on TAB, complete options for system command
o.wildignore = 'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc'
-- Mappings {{{
local map = vim.keymap.set
map({'n','v'}, '<Space>', "<Nop>", { silent = true })
-- clear the search buffer when hitting return
map('n', '<CR>', '{->v:hlsearch ? ":nohl\\<CR>" : "\\<CR>"}()', { expr = true })
-- sane regexes
map({'n','v'}, '/', '/\\v', { noremap = true, silent = true })
-- don't jump when using *
map('n','*', '*<c-o>')
-- keep search matches in the middle of the window
map('n','n', 'nzzzv')
map('n','N', 'Nzzzv')
-- Same when jumping around
map('n','g;', 'g;zz', { silent = true })
-- replace ex mode map and use it for repeating 'q' macro
map('n','Q', '@q', { silent = true })
map('v','Q', '<cmd>norm @q<CR>', { silent = true })
-- Shortcut to close quickfix windows
map('n','<leader>a', '<cmd>windo lcl|ccl<CR>', { silent = true })
-- <Leader>q Closes the current buffer
map('n','<leader>q', '<cmd>bdelete<CR>', { silent = true })
-- Easier in-file navigation with Tab and S-Tab
map('n','<S-Tab>', '<C-U>')
map('n','<Tab>', '<C-D>')
-- more natural movement with wrap on
map({'n','v'},'j', 'gj', { noremap = true, silent = true })
map({'n','v'},'k', 'gk', { noremap = true, silent = true })
-- Easy buffer navigation
map('n','<C-h>', '<C-w>h', { silent = true })
map('n','<C-j>', '<C-w>j', { silent = true })
map('n','<C-k>', '<C-w>k', { silent = true })
map('n','<C-l>', '<C-w>l', { silent = true })
map('n','<up>', '<cmd>resize -2<CR>', { silent = true })
map('n','<down>', '<cmd>resize +2<CR>', { silent = true })
map('n','<left>', '<cmd>vertical resize -2<CR>', { silent = true })
map('n','<right>', '<cmd>vertical resize +2<CR>', { silent = true })
map({'n','i'},"<leader>s", "<cmd>HopChar2<cr>", { silent = true })
map('n',"<leader>w", "<cmd>HopWord<cr>", { silent = true })
map('n',"<silent><F6>", "<cmd>:set invspell<cr>", { silent = true })
--}}}