aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/nvim/ftplugin/c.vim7
-rw-r--r--config/nvim/ftplugin/cpp.vim8
-rw-r--r--config/nvim/ftplugin/json.vim1
-rw-r--r--config/nvim/ftplugin/lua.vim2
-rw-r--r--config/nvim/ftplugin/nix.vim5
-rw-r--r--config/nvim/ftplugin/python.vim2
-rw-r--r--config/nvim/ftplugin/sh.vim2
-rw-r--r--config/nvim/ftplugin/tex.vim1
-rw-r--r--config/nvim/init.vim131
-rw-r--r--config/nvim/lua/mytelescope.lua205
-rw-r--r--config/nvim/lua/plugins.lua97
-rw-r--r--config/nvim/selene-vim.yml5
-rw-r--r--config/nvim/selene.toml4
13 files changed, 470 insertions, 0 deletions
diff --git a/config/nvim/ftplugin/c.vim b/config/nvim/ftplugin/c.vim
new file mode 100644
index 0000000..3769d80
--- /dev/null
+++ b/config/nvim/ftplugin/c.vim
@@ -0,0 +1,7 @@
+let b:ale_linters = ['cppcheck', 'flawfinder']
+let b:ale_fixers = ['clang-format', 'remove_trailing_lines', 'trim_whitespace']
+let g:ale_c_parse_compile_commands = 1
+let g:ale_c_clangd_options = '--header-insertion=never'
+
+nmap <F8> :ALENext<cr>
+nmap <F7> :ALEPrevious<cr>
diff --git a/config/nvim/ftplugin/cpp.vim b/config/nvim/ftplugin/cpp.vim
new file mode 100644
index 0000000..89944ea
--- /dev/null
+++ b/config/nvim/ftplugin/cpp.vim
@@ -0,0 +1,8 @@
+" This is for C but vim defines *.h as cpp type so here we have it
+let b:ale_linters = ['ccls', 'cppcheck', 'flawfinder']
+let b:ale_fixers = ['clang-format', 'remove_trailing_lines', 'trim_whitespace']
+let g:ale_cpp_ccls_init_options = {'cache': {'directory': '/tmp/ccls/cache'}}
+let g:ale_cpp_parse_compile_commands = 1
+
+nmap <F8> :ALENext<cr>
+nmap <F7> :ALEPrevious<cr>
diff --git a/config/nvim/ftplugin/json.vim b/config/nvim/ftplugin/json.vim
new file mode 100644
index 0000000..829a37e
--- /dev/null
+++ b/config/nvim/ftplugin/json.vim
@@ -0,0 +1 @@
+let b:ale_fixers = ['jq']
diff --git a/config/nvim/ftplugin/lua.vim b/config/nvim/ftplugin/lua.vim
new file mode 100644
index 0000000..733962a
--- /dev/null
+++ b/config/nvim/ftplugin/lua.vim
@@ -0,0 +1,2 @@
+let b:ale_linters = ['luacheck', 'selene', 'luac']
+let b:ale_fixers = ['stylua', 'remove_trailing_lines', 'trim_whitespace']
diff --git a/config/nvim/ftplugin/nix.vim b/config/nvim/ftplugin/nix.vim
new file mode 100644
index 0000000..48be358
--- /dev/null
+++ b/config/nvim/ftplugin/nix.vim
@@ -0,0 +1,5 @@
+let b:ale_linters = ['nix', 'statix']
+let b:ale_fixers = ['alejandra', 'remove_trailing_lines', 'trim_whitespace']
+
+nmap <F8> :ALENext<cr>
+nmap <F7> :ALEPrevious<cr>
diff --git a/config/nvim/ftplugin/python.vim b/config/nvim/ftplugin/python.vim
new file mode 100644
index 0000000..94b035a
--- /dev/null
+++ b/config/nvim/ftplugin/python.vim
@@ -0,0 +1,2 @@
+let b:ale_linters = ['pylint', 'mypy', 'pydocstyle']
+let b:ale_fixers = ['isort', 'black', 'remove_trailing_lines', 'trim_whitespace']
diff --git a/config/nvim/ftplugin/sh.vim b/config/nvim/ftplugin/sh.vim
new file mode 100644
index 0000000..8cc42e2
--- /dev/null
+++ b/config/nvim/ftplugin/sh.vim
@@ -0,0 +1,2 @@
+let b:ale_linters = ['shell', 'shellcheck']
+let b:ale_fixers = ['shfmt', 'trim_whitespace', 'remove_trailing_lines']
diff --git a/config/nvim/ftplugin/tex.vim b/config/nvim/ftplugin/tex.vim
new file mode 100644
index 0000000..5eb1926
--- /dev/null
+++ b/config/nvim/ftplugin/tex.vim
@@ -0,0 +1 @@
+let b:ale_linters = ['lacheck']
diff --git a/config/nvim/init.vim b/config/nvim/init.vim
new file mode 100644
index 0000000..b538453
--- /dev/null
+++ b/config/nvim/init.vim
@@ -0,0 +1,131 @@
+augroup user_config
+ autocmd!
+ autocmd BufWritePost init.vim source <afile>
+augroup end
+
+lua require('plugins')
+augroup packer_user_config
+ autocmd!
+ autocmd BufWritePost plugins.lua source <afile> | PackerCompile
+augroup end
+
+
+set exrc
+set secure
+set title
+
+set hidden
+set undofile
+set undodir=~/.cache/nvim-undo//
+set directory=$HOME/.cache/nvim//
+set hlsearch
+set wildmode=longest:full,full
+set wildmenu
+set modeline
+set encoding=utf-8
+
+
+set backspace=indent,eol,start
+
+colorscheme nord
+let g:lightline = { 'colorscheme': 'nord' }
+
+set number
+set colorcolumn=80
+set textwidth=80
+
+
+" Tabs setting. In default we want 4 spaces tab, but allows also 8 spaced tabs
+set noexpandtab
+set tabstop=4
+set shiftwidth=4
+set softtabstop=4
+function TabToogle()
+ if &tabstop != 4
+ set tabstop=4
+ set shiftwidth=4
+ set softtabstop=4
+ echom 'Tab stop set to 4'
+ else
+ set tabstop=8
+ set shiftwidth=8
+ set softtabstop=8
+ echom 'Tab stop set to 8'
+ endif
+ " Soft tab stop is here only for possibility of expandtab
+endfunction
+command TabToogle call TabToogle()
+
+" Translate word under cursor
+nnoremap <leader>d :! sdcv -n <cword><cr>
+
+" netrw configuration
+cabbrev E Explore
+let g:netrw_banner=0
+let g:netrw_liststyle=1
+let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+,'
+function GitIgnore()
+ " Possibly find and include all lower .gitignore files?
+ let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+,' . netrw_gitignore#Hide()
+endfunction
+command GitIgnore call GitIgnore()
+" Some fast buffer switching and opening of new files
+nnoremap <c-c><CR> :Explore<cr>
+nnoremap <c-c>l :bnext<cr>
+nnoremap <c-c>h :bprev<cr>
+
+" Setup gitgutter
+set updatetime=100
+highlight GitGutterAdd ctermfg=2
+highlight GitGutterChange ctermfg=3
+highlight GitGutterDelete ctermfg=1
+
+" Setup table-mode to markdown compliant
+" Note: to start use "\ t m"
+let g:table_mode_corner='|'
+
+" Open tagbar with <F9>
+nmap <F9> :TagbarOpen fc<cr>
+
+" Spell checking
+map <F10> :setlocal spell!<cr>
+function LangToggle()
+ if &spelllang !=? 'en_us'
+ setlocal spelllang=en_us
+ echo 'spelllang=en_us'
+ else
+ setlocal spelllang=cs
+ echo 'spelllang=cs'
+ endif
+endfunction
+setlocal spelllang=en_us
+map <F11> :call LangToggle()<cr>
+
+" NERDCommenter
+let g:NERDCreateDefaultMappings = 1
+
+" UltiSnips triggers
+let g:UltiSnipsExpandTrigger='<c-h>'
+let g:UltiSnipsJumpForwardTrigger='<c-j>'
+let g:UltiSnipsJumpBackwardTrigger='<c-k>'
+
+" ALE
+let g:ale_set_baloons = 1
+let g:ale_floating_preview = 1
+let g:ale_use_neovim_diagnostics_api = 1
+nmap <leader>f <Plug>(ale_fix)
+
+" Telescope
+nnoremap <c-c><c-c> :Telescope buffers<cr>
+nnoremap <expr> <c-p> ":lua require'telescope.builtin'.git_files{}<cr>".expand('%:h')."/"
+nnoremap <c-s-p> :Telescope lsp_document_symbols<cr>
+nmap <leader>] :Telescope lsp_definitions<cr>
+nmap <leader><leader>] :Telescope lsp_type_definitions<cr>
+nmap <leader>[ :Telescope lsp_implementations<cr>
+nmap <leader><leader>[ :Telescope lsp_references<cr>
+
+" Copy line location
+" TODO this should work but it doesn't for some reason
+" nmap <leader><leader>c :let @+=expand("%:p") . ":" . line(".")<cr>
+nmap <leader><leader>c :exec "!wl-copy '" . expand("%:p") . ":" . line(".") . "'"<cr><cr>
+
diff --git a/config/nvim/lua/mytelescope.lua b/config/nvim/lua/mytelescope.lua
new file mode 100644
index 0000000..c4fe3a7
--- /dev/null
+++ b/config/nvim/lua/mytelescope.lua
@@ -0,0 +1,205 @@
+local layout = require("nui.layout")
+local popup = require("nui.popup")
+
+local actions = require("telescope.actions")
+
+local tslayout = require("telescope.pickers.layout")
+
+return require("telescope").setup({
+ defaults = {
+ mappings = {
+ i = {
+ ["<esc>"] = actions.close,
+ ["<c-j>"] = actions.move_selection_next,
+ ["<c-k>"] = actions.move_selection_previous,
+ ["<c-u>"] = false,
+ },
+ },
+
+ create_layout = function(picker)
+ local border = {
+ results = {
+ top_left = "┌",
+ top = "─",
+ top_right = "┬",
+ right = "│",
+ bottom_right = "",
+ bottom = "",
+ bottom_left = "",
+ left = "│",
+ },
+ results_patch = {
+ minimal = {
+ top_left = "┌",
+ top_right = "┐",
+ },
+ horizontal = {
+ top_left = "┌",
+ top_right = "┬",
+ },
+ vertical = {
+ top_left = "├",
+ top_right = "┤",
+ },
+ },
+ prompt = {
+ top_left = "├",
+ top = "─",
+ top_right = "┤",
+ right = "│",
+ bottom_right = "┘",
+ bottom = "─",
+ bottom_left = "└",
+ left = "│",
+ },
+ prompt_patch = {
+ minimal = {
+ bottom_right = "┘",
+ },
+ horizontal = {
+ bottom_right = "┴",
+ },
+ vertical = {
+ bottom_right = "┘",
+ },
+ },
+ preview = {
+ top_left = "┌",
+ top = "─",
+ top_right = "┐",
+ right = "│",
+ bottom_right = "┘",
+ bottom = "─",
+ bottom_left = "└",
+ left = "│",
+ },
+ preview_patch = {
+ minimal = {},
+ horizontal = {
+ bottom = "─",
+ bottom_left = "",
+ bottom_right = "┘",
+ left = "",
+ top_left = "",
+ },
+ vertical = {
+ bottom = "",
+ bottom_left = "",
+ bottom_right = "",
+ left = "│",
+ top_left = "┌",
+ },
+ },
+ }
+
+ local results = popup({
+ focusable = false,
+ border = {
+ style = border.results,
+ text = {
+ top = picker.results_title,
+ top_align = "center",
+ },
+ },
+ win_options = {
+ winhighlight = "Normal:Normal",
+ },
+ })
+
+ local prompt = popup({
+ enter = true,
+ border = {
+ style = border.prompt,
+ text = {
+ top = picker.prompt_title,
+ top_align = "center",
+ },
+ },
+ win_options = {
+ winhighlight = "Normal:Normal",
+ },
+ })
+
+ local preview = popup({
+ focusable = false,
+ border = {
+ style = border.preview,
+ text = {
+ top = picker.preview_title,
+ top_align = "center",
+ },
+ },
+ })
+
+ local box_by_kind = {
+ vertical = layout.Box({
+ layout.Box(preview, { grow = 1 }),
+ layout.Box(results, { grow = 1 }),
+ layout.Box(prompt, { size = 3 }),
+ }, { dir = "col" }),
+ horizontal = layout.Box({
+ layout.Box({
+ layout.Box(results, { grow = 1 }),
+ layout.Box(prompt, { size = 3 }),
+ }, { dir = "col", size = "50%" }),
+ layout.Box(preview, { size = "50%" }),
+ }, { dir = "row" }),
+ minimal = layout.Box({
+ layout.Box(results, { grow = 1 }),
+ layout.Box(prompt, { size = 3 }),
+ }, { dir = "col" }),
+ }
+
+ local function get_box()
+ local height, width = vim.o.lines, vim.o.columns
+ local box_kind = "horizontal"
+ if width < 100 then
+ box_kind = "vertical"
+ if height < 40 then
+ box_kind = "minimal"
+ end
+ elseif width < 120 then
+ box_kind = "minimal"
+ end
+ return box_by_kind[box_kind], box_kind
+ end
+
+ local function prepare_layout_parts(layout, box_type)
+ layout.results = tslayout.Window(results)
+ results.border:set_style(border.results_patch[box_type])
+
+ layout.prompt = tslayout.Window(prompt)
+ prompt.border:set_style(border.prompt_patch[box_type])
+
+ if box_type == "minimal" then
+ layout.preview = nil
+ else
+ layout.preview = tslayout.Window(preview)
+ preview.border:set_style(border.preview_patch[box_type])
+ end
+ end
+
+ local box, box_kind = get_box()
+ local layout = layout({
+ relative = "editor",
+ position = "50%",
+ size = {
+ height = "60%",
+ width = "90%",
+ },
+ }, box)
+
+ layout.picker = picker
+ prepare_layout_parts(layout, box_kind)
+
+ local layout_update = layout.update
+ function layout:update()
+ local box, box_kind = get_box()
+ prepare_layout_parts(layout, box_kind)
+ layout_update(self, box)
+ end
+
+ return tslayout(layout)
+ end,
+ },
+})
diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua
new file mode 100644
index 0000000..b60f913
--- /dev/null
+++ b/config/nvim/lua/plugins.lua
@@ -0,0 +1,97 @@
+local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
+if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
+ vim.fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
+ vim.cmd([[packadd packer.nvim]])
+end
+
+require("packer").startup(function(use)
+ use("wbthomason/packer.nvim")
+ -- Visual
+ use("shaunsingh/nord.nvim")
+ use("MunifTanjim/nui.nvim")
+ use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
+ use("lukas-reineke/indent-blankline.nvim")
+ use("itchyny/lightline.vim")
+ -- Files navigation
+ use("nvim-lua/plenary.nvim")
+ use("nvim-telescope/telescope.nvim")
+ -- Git
+ use("tpope/vim-fugitive")
+ use("airblade/vim-gitgutter")
+ use({
+ "harrisoncramer/gitlab.nvim",
+ requires = {
+ "MunifTanjim/nui.nvim",
+ "nvim-lua/plenary.nvim",
+ "sindrets/diffview.nvim",
+ "stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
+ "nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
+ },
+ run = function()
+ require("gitlab.server").build(true)
+ end,
+ })
+ -- Programming
+ use("neovim/nvim-lspconfig")
+ use("p00f/clangd_extensions.nvim")
+ use("w0rp/ale")
+ use("maximbaz/lightline-ale")
+ use("SirVer/ultisnips")
+ use("honza/vim-snippets")
+ use("craigemery/vim-autotag")
+ use("scrooloose/nerdcommenter")
+ -- Movement, format and others
+ use("tpope/vim-surround")
+ use("tpope/vim-repeat")
+ use("dhruvasagar/vim-table-mode")
+
+-- Indent blanklike character specificaiton
+local highlight = { "CursorColumn", "Whitespace" }
+require("ibl").setup({
+ indent = { highlight = highlight, char = "" },
+ whitespace = {
+ highlight = highlight,
+ remove_blankline_trail = false,
+ },
+ scope = { enabled = false },
+})
+-- Treesitter
+require("nvim-treesitter.configs").setup({
+ ensure_installed = {
+ "c",
+ "lua",
+ "kconfig",
+ "make",
+ "markdown",
+ "meson",
+ "ninja",
+ "ini",
+ "gitcommit",
+ "git_rebase",
+ "git_config",
+ "nix",
+ "python",
+ "toml",
+ "vim",
+ "vimdoc",
+ "yaml",
+ },
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ },
+})
+
+-- LSP
+local lspconfig = require("lspconfig")
+lspconfig.clangd.setup({})
+lspconfig.rnix.setup({})
+lspconfig.pylsp.setup({})
+lspconfig.bashls.setup({})
+
+-- Telescope
+require('mytelescope')
+
+-- Gitlab
+require("diffview").setup()
+require("gitlab").setup()
diff --git a/config/nvim/selene-vim.yml b/config/nvim/selene-vim.yml
new file mode 100644
index 0000000..53daa57
--- /dev/null
+++ b/config/nvim/selene-vim.yml
@@ -0,0 +1,5 @@
+---
+base: lua51
+globals:
+ vim:
+ any: true
diff --git a/config/nvim/selene.toml b/config/nvim/selene.toml
new file mode 100644
index 0000000..39b4859
--- /dev/null
+++ b/config/nvim/selene.toml
@@ -0,0 +1,4 @@
+std = "selene-vim"
+
+[lints]
+mixed_table = "allow"