dotfiles/dot_config/nvim/init.lua.tmpl

304 lines
8.1 KiB
Cheetah
Raw Normal View History

2023-02-11 14:11:00 +01:00
HOME = os.getenv("HOME")
vim.cmd([[colorscheme gruvbox]])
2023-02-24 07:31:04 +01:00
vim.g.mapleader = ' '
2023-02-11 14:11:00 +01:00
vim.g.maplocalleader = '\\'
-- Plugins
require "paq" {
2023-02-27 07:44:10 +01:00
"savq/paq-nvim",
2023-02-11 14:11:00 +01:00
2023-02-27 07:44:10 +01:00
"nvim-treesitter/nvim-treesitter",
"nvim-treesitter/nvim-treesitter-textobjects",
2023-02-11 14:11:00 +01:00
2023-02-24 11:03:09 +01:00
-- Theming
2023-02-27 07:44:10 +01:00
"ellisonleao/gruvbox.nvim",
"nvim-lualine/lualine.nvim",
"nvim-tree/nvim-web-devicons",
"lukas-reineke/indent-blankline.nvim",
2023-02-11 14:11:00 +01:00
-- LSP support
2023-02-27 07:44:10 +01:00
"onsails/lspkind.nvim",
"lukas-reineke/lsp-format.nvim",
"neovim/nvim-lspconfig",
2023-02-24 11:03:09 +01:00
{{- if ne .chezmoi.os "openbsd" }}
2023-02-27 07:44:10 +01:00
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
2023-02-24 11:03:09 +01:00
{{- end }}
2023-02-11 14:11:00 +01:00
-- Autocomplete
2023-02-27 07:44:10 +01:00
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
2023-02-11 14:11:00 +01:00
-- Snippets
2023-02-27 07:44:10 +01:00
"L3MON4D3/LuaSnip",
"rafamadriz/friendly-snippets",
2023-02-11 14:11:00 +01:00
2023-02-24 07:31:04 +01:00
-- Programming support
2023-02-27 07:44:10 +01:00
"kylechui/nvim-surround",
"windwp/nvim-autopairs",
"numToStr/Comment.nvim",
"ggandor/leap.nvim",
2023-02-11 14:11:00 +01:00
-- Fuzzy search
2023-02-27 07:44:10 +01:00
{ "nvim-telescope/telescope-fzf-native.nvim", run = "gmake" },
"nvim-telescope/telescope-file-browser.nvim",
"nvim-telescope/telescope.nvim",
"folke/trouble.nvim",
"mfussenegger/nvim-dap",
"theHamsta/nvim-dap-virtual-text",
"rcarriga/nvim-dap-ui",
"norcalli/nvim-colorizer.lua",
"lewis6991/gitsigns.nvim",
"tpope/vim-fugitive",
"renerocksai/telekasten.nvim",
"renerocksai/calendar-vim",
"nvim-lua/plenary.nvim",
"akinsho/toggleterm.nvim",
2023-02-11 14:11:00 +01:00
}
require('nvim-web-devicons').setup {}
require('nvim-surround').setup()
require('Comment').setup()
require('dapui').setup()
require('gitsigns').setup()
2023-02-24 09:19:42 +01:00
require("trouble").setup {}
2023-02-24 07:31:04 +01:00
require('nvim-autopairs').setup({
2023-02-24 09:19:42 +01:00
fast_wrap = {},
2023-04-30 10:02:05 +02:00
check_ts = true
2023-02-24 07:31:04 +01:00
})
2023-02-25 06:42:21 +01:00
require('leap').add_default_mappings()
2023-02-24 07:31:04 +01:00
require 'colorizer'.setup {
2023-02-24 09:19:42 +01:00
filetypes = {
'css',
'javascript',
2023-02-27 07:44:10 +01:00
scss = { rgb_fn = true, },
html = { mode = 'foreground', }
2023-02-24 09:19:42 +01:00
},
2023-02-24 07:31:04 +01:00
}
2023-02-11 14:11:00 +01:00
require('lualine').setup {
options = {
icons_enabled = true,
theme = 'gruvbox',
component_separators = '|',
section_separators = '',
}
}
2023-02-24 11:03:09 +01:00
require('indent_blankline').setup({
2023-02-25 06:42:21 +01:00
char = '▏',
show_trailing_blankline_indent = false,
show_first_indent_level = false,
use_treesitter = true,
show_current_context = false
2023-02-24 11:03:09 +01:00
})
2023-02-24 07:31:04 +01:00
require('toggleterm').setup({
2023-02-24 09:19:42 +01:00
open_mapping = '<C-g>',
direction = 'horizontal',
shade_terminals = true
2023-02-24 07:31:04 +01:00
})
2023-02-11 14:11:00 +01:00
require("gruvbox").setup {
contrast = "hard"
}
-- Options
2023-02-27 07:44:10 +01:00
local o = vim.opt
2023-02-11 14:11:00 +01:00
-- basic settings
2023-02-27 07:44:10 +01:00
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
2023-02-24 07:31:04 +01:00
-- o.dictionary = '/home/jan/.vim/dict/words'
-- o.dictionary = '/usr/share/dict/words'
2023-02-27 07:44:10 +01:00
o.startofline = true
o.title = true
o.clipboard = 'unnamedplus'
2023-02-11 14:11:00 +01:00
-- Mapping waiting time
2023-02-27 07:44:10 +01:00
o.timeoutlen = 200
o.ttimeoutlen = 0
2023-02-11 14:11:00 +01:00
-- Spellchecker
2023-02-27 07:44:10 +01:00
o.spell = false
o.spelllang = { 'en_us' }
o.spellfile = HOME .. '/.vim/spell/en.utf8.add'
o.thesaurus = HOME .. '/.vim/thesaurus/english.txt'
2023-02-11 14:11:00 +01:00
-- Display
2023-02-24 09:19:42 +01:00
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
2023-02-11 14:11:00 +01:00
o.termguicolors = true
2023-02-24 09:19:42 +01:00
o.background = "dark"
2023-02-27 07:44:10 +01:00
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
2023-02-11 14:11:00 +01:00
-- Folding
2023-02-27 07:44:10 +01:00
o.foldenable = true
o.foldnestmax = 2
o.foldminlines = 10
o.foldmethod = "expr"
o.foldexpr = "nvim_treesitter#foldexpr()"
-- workaround for Telescope bug
vim.api.nvim_create_autocmd({ "BufEnter" }, {
pattern = { "*" },
command = "normal zx",
})
2023-02-11 14:11:00 +01:00
-- Sidebar
o.number = true -- line number on the left
o.relativenumber = true
o.numberwidth = 3 -- always reserve 3 spaces for line number
2023-02-24 07:31:04 +01:00
o.signcolumn = 'yes'
2023-02-11 14:11:00 +01:00
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
2023-02-24 09:19:42 +01:00
o.undodir = HOME .. '/.local/share/nvim/dirs/undo//' -- undo files
2023-02-24 07:31:04 +01:00
o.backupdir = HOME .. '/.local/share/nvim/dirs/backup//' -- backups
2023-02-11 14:11:00 +01:00
-- Commands mode
o.wildmenu = true -- on TAB, complete options for system command
2023-02-27 07:44:10 +01:00
o.wildignore =
'deps,.svn,CVS,.git,.hg,*.o,*.a,*.class,*.mo,*.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,.DS_Store,*.aux,*.out,*.toc'
2023-02-11 14:11:00 +01:00
2023-02-24 07:31:04 +01:00
vim.cmd([[
au BufRead,BufNewFile *.md set ft=mkd tw=80 syntax=markdown
]])
vim.api.nvim_create_user_command('ReloadConfig', 'source $MYVIMRC', {})
2023-02-24 09:19:42 +01:00
local group = vim.api.nvim_create_augroup('user_cmds', { clear = true })
2023-02-24 07:31:04 +01:00
vim.api.nvim_create_autocmd('TextYankPost', {
2023-02-24 09:19:42 +01:00
desc = 'Highlight on yank',
group = group,
callback = function()
vim.highlight.on_yank({ higroup = 'Visual', timeout = 200 })
end,
2023-02-24 07:31:04 +01:00
})
2023-02-11 14:11:00 +01:00
local map = vim.keymap.set
2023-02-24 09:19:42 +01:00
map({ 'n', 'v' }, '<Space>', "<Nop>", { silent = true })
2023-02-11 14:11:00 +01:00
-- clear the search buffer when hitting return
map('n', '<CR>', '{->v:hlsearch ? ":nohl\\<CR>" : "\\<CR>"}()', { expr = true })
-- sane regexes
2023-02-24 09:19:42 +01:00
map({ 'n', 'v' }, '/', '/\\v', { noremap = true, silent = true })
2023-02-11 14:11:00 +01:00
-- don't jump when using *
2023-02-24 09:19:42 +01:00
map('n', '*', '*<c-o>')
2023-02-11 14:11:00 +01:00
-- keep search matches in the middle of the window
2023-02-24 09:19:42 +01:00
map('n', 'n', 'nzzzv')
map('n', 'N', 'Nzzzv')
2023-02-11 14:11:00 +01:00
-- Same when jumping around
2023-02-24 09:19:42 +01:00
map('n', 'g;', 'g;zz')
2023-02-11 14:11:00 +01:00
-- replace ex mode map and use it for repeating 'q' macro
2023-02-24 09:19:42 +01:00
map('n', 'Q', '@q')
map('v', 'Q', '<cmd>norm @q<CR>')
2023-02-11 14:11:00 +01:00
-- Shortcut to close quickfix windows
2023-02-24 09:19:42 +01:00
map('n', '<leader>a', '<cmd>windo lcl|ccl<CR>')
2023-02-11 14:11:00 +01:00
-- <Leader>q Closes the current buffer
2023-02-24 09:19:42 +01:00
map('n', '<leader>q', '<cmd>bdelete<CR>')
2023-02-11 14:11:00 +01:00
-- Easier in-file navigation with Tab and S-Tab
2023-02-24 09:19:42 +01:00
map('n', '<S-Tab>', '<C-U>')
map('n', '<Tab>', '<C-D>')
2023-02-11 14:11:00 +01:00
-- Easy buffer navigation
2023-02-24 09:19:42 +01:00
map('n', '<C-h>', '<C-w>h')
map('n', '<C-j>', '<C-w>j')
map('n', '<C-k>', '<C-w>k')
map('n', '<C-l>', '<C-w>l')
map('n', '<up>', '<cmd>resize -2<CR>')
map('n', '<down>', '<cmd>resize +2<CR>')
map('n', '<left>', '<cmd>vertical resize -2<CR>')
map('n', '<right>', '<cmd>vertical resize +2<CR>')
-- Trouble keymap
map('n', '<leader>xx', '<cmd>TroubleToggle<cr>', { noremap = true, silent = true })
map('n', '<leader>xd', '<cmd>TroubleToggle document_diagnostics<cr>', { noremap = true, silent = true })
map('n', '<leader>xl', '<cmd>TroubleToggle loclist<cr>', { noremap = true, silent = true })
map('n', '<leader>xq', '<cmd>TroubleToggle quickfix<cr>', { noremap = true, silent = true })
2023-02-25 06:42:21 +01:00
map('n', '<leader>g', '<cmd>vertical rightbelow Git<cr>', { noremap = true, silent = true })