aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2024-03-13 10:52:06 +0100
committerKarel Kočí <cynerd@email.cz>2024-03-13 10:52:06 +0100
commite511f8e110fa5200d667ebee2e7403dbe98721ef (patch)
tree2f35a8033bb77e22013c4ed80a7d6819485f8084
parent68cd653842a300081d54f0c539e32c8774f824a4 (diff)
downloadmyconfigs-e511f8e110fa5200d667ebee2e7403dbe98721ef.tar.gz
myconfigs-e511f8e110fa5200d667ebee2e7403dbe98721ef.tar.bz2
myconfigs-e511f8e110fa5200d667ebee2e7403dbe98721ef.zip
nvim: switch from ale and other tweaks
-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.vim47
-rw-r--r--config/nvim/lua/plugins.lua191
10 files changed, 164 insertions, 102 deletions
diff --git a/config/nvim/ftplugin/c.vim b/config/nvim/ftplugin/c.vim
deleted file mode 100644
index 3769d80..0000000
--- a/config/nvim/ftplugin/c.vim
+++ /dev/null
@@ -1,7 +0,0 @@
-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
deleted file mode 100644
index 89944ea..0000000
--- a/config/nvim/ftplugin/cpp.vim
+++ /dev/null
@@ -1,8 +0,0 @@
-" 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
deleted file mode 100644
index 829a37e..0000000
--- a/config/nvim/ftplugin/json.vim
+++ /dev/null
@@ -1 +0,0 @@
-let b:ale_fixers = ['jq']
diff --git a/config/nvim/ftplugin/lua.vim b/config/nvim/ftplugin/lua.vim
deleted file mode 100644
index 733962a..0000000
--- a/config/nvim/ftplugin/lua.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-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
deleted file mode 100644
index 48be358..0000000
--- a/config/nvim/ftplugin/nix.vim
+++ /dev/null
@@ -1,5 +0,0 @@
-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
deleted file mode 100644
index 94b035a..0000000
--- a/config/nvim/ftplugin/python.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-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
deleted file mode 100644
index 8cc42e2..0000000
--- a/config/nvim/ftplugin/sh.vim
+++ /dev/null
@@ -1,2 +0,0 @@
-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
deleted file mode 100644
index 5eb1926..0000000
--- a/config/nvim/ftplugin/tex.vim
+++ /dev/null
@@ -1 +0,0 @@
-let b:ale_linters = ['lacheck']
diff --git a/config/nvim/init.vim b/config/nvim/init.vim
index 1d0e6c6..491ae47 100644
--- a/config/nvim/init.vim
+++ b/config/nvim/init.vim
@@ -28,11 +28,36 @@ set backspace=indent,eol,start
set completeopt=menu,menuone,preview,noselect,noinsert
colorscheme nord
-let g:lightline = { 'colorscheme': 'nord' }
+let g:lightline = {
+\ 'colorscheme': 'nord',
+\ 'active': {
+\ 'left': [
+\ [ 'mode', 'paste' ],
+\ [ 'lsp_info', 'lsp_hints', 'lsp_errors', 'lsp_warnings', 'lsp_ok' ],
+\ [ 'lsp_status' ],
+\ [ 'readonly', 'filename', 'modified' ],
+\ ]
+\ },
+\ 'component': {
+\ 'lineinfo': ' %3l:%-2v',
+\ },
+\ 'component_function': {
+\ 'readonly': 'LightlineReadonly',
+\ },
+\ 'separator': { 'left': '', 'right': '' },
+\ 'subseparator': { 'left': '', 'right': '' }
+\ }
+function! LightlineReadonly()
+ return &readonly ? '' : ''
+endfunction
+call lightline#lsp#register()
+set laststatus=2
+set noshowmode
set number
set colorcolumn=80
set textwidth=80
+nmap <c-/> :noh<cr>
" Tabs setting. In default we want 4 spaces tab, but allows also 8 spaced tabs
@@ -74,6 +99,9 @@ nnoremap <c-c><CR> :Explore<cr>
nnoremap <c-c>l :bnext<cr>
nnoremap <c-c>h :bprev<cr>
+" Format
+nmap <leader>f :lua require("conform").format()<cr>
+
" Setup gitgutter
set updatetime=100
highlight GitGutterAdd ctermfg=2
@@ -84,9 +112,6 @@ highlight GitGutterDelete ctermfg=1
" 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()
@@ -109,20 +134,15 @@ 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> ":call TelescopeFiles()<cr>".expand('%:h')."/"
+nnoremap <c-p> :call TelescopeFiles()<cr>
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>
+nmap <F9> :Telescope diagnostics bufnr=0<cr>
function TelescopeFiles()
if stridx(system('git rev-parse --is-inside-work-tree 2>/dev/null || true'), 'true') != -1
lua require('telescope.builtin').git_files{use_file_path=true,git_command={"sh","-c","git ls-files -c --recurse-submodules && git ls-files -o --exclude-standard"}}
@@ -132,7 +152,4 @@ function TelescopeFiles()
endfunction
" 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>
-
+nmap <leader><leader>c :let @+=expand("%:p") . ":" . line(".")<cr>
diff --git a/config/nvim/lua/plugins.lua b/config/nvim/lua/plugins.lua
index fa736e3..6e33f5b 100644
--- a/config/nvim/lua/plugins.lua
+++ b/config/nvim/lua/plugins.lua
@@ -4,18 +4,68 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.cmd([[packadd packer.nvim]])
end
+local treesitter_formaters = {
+ "c",
+ "lua",
+ "kconfig",
+ "make",
+ "markdown",
+ "markdown_inline",
+ "meson",
+ "ninja",
+ "ini",
+ "gitcommit",
+ "git_rebase",
+ "git_config",
+ "nix",
+ "python",
+ "toml",
+ "vim",
+ "vimdoc",
+ "yaml",
+}
+
require("packer").startup(function(use)
use("wbthomason/packer.nvim")
- -- Visual
+ -- Visual ------------------------------------------------------------------
use("shaunsingh/nord.nvim")
use("MunifTanjim/nui.nvim")
- use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" })
- use("lukas-reineke/indent-blankline.nvim")
+ use({
+ "nvim-treesitter/nvim-treesitter",
+ run = ":TSUpdate",
+ config = function()
+ require("nvim-treesitter.configs").setup({
+ ensure_installed = treesitter_formaters,
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = false,
+ },
+ })
+ end,
+ })
+ use({
+ "lukas-reineke/indent-blankline.nvim",
+ config = function()
+ local highlight = { "CursorColumn", "Whitespace" }
+ require("ibl").setup({
+ indent = { highlight = highlight, char = "" },
+ whitespace = {
+ highlight = highlight,
+ remove_blankline_trail = false,
+ },
+ scope = { enabled = false },
+ })
+ end,
+ })
use("itchyny/lightline.vim")
- -- Files navigation
- use("nvim-lua/plenary.nvim")
- use("nvim-telescope/telescope.nvim")
- -- Git
+ use("josa42/nvim-lightline-lsp")
+ use({
+ "nvim-telescope/telescope.nvim",
+ config = function()
+ require("mytelescope")
+ end,
+ })
+ -- Git ---------------------------------------------------------------------
use("tpope/vim-fugitive")
use("airblade/vim-gitgutter")
use({
@@ -30,71 +80,94 @@ require("packer").startup(function(use)
run = function()
require("gitlab.server").build(true)
end,
+ config = function()
+ require("diffview").setup()
+ require("gitlab").setup()
+ end,
})
- -- Programming
+ -- Programming -------------------------------------------------------------
use("neovim/nvim-lspconfig")
use("p00f/clangd_extensions.nvim")
- use("w0rp/ale")
- use("maximbaz/lightline-ale")
+ use({
+ "mfussenegger/nvim-lint",
+ config = function()
+ local lint = require("lint")
+ lint.linters_by_ft = {
+ c = { "cppcheck", "flawfinder", "editorconfig-checker" },
+ lua = { "selene", "editorconfig-checker" },
+ markdown = { "vale" },
+ nix = { "statix", "deadnix", "nix", "editorconfig-checker" },
+ python = { "pylint", "mypy", "pydocstyle", "editorconfig-checker" },
+ sh = { "shellcheck", "editorconfig-checker" },
+ }
+ lint.linters.deadnix = {
+ cmd = "deadnix",
+ stdin = false,
+ args = { "--output-format", "json" },
+ stream = "stdout",
+ parser = function(output)
+ local lines = vim.fn.split(output, "\n")
+ local diagnostics = {}
+ for _, line in ipairs(lines) do
+ local ok, decoded = pcall(vim.json.decode, line)
+ if ok and decoded.file ~= nil then
+ for _, result in ipairs(decoded.results) do
+ table.insert(diagnostics, {
+ lnum = result.line,
+ end_lnum = result.line,
+ col = result.column,
+ end_col = result.endColumn,
+ severity = vim.diagnostic.severity.HINT,
+ source = "deadnix",
+ message = result.message,
+ })
+ end
+ end
+ end
+ return diagnostics
+ end,
+ }
+ vim.api.nvim_create_autocmd({ "BufReadPost", "BufWrite", "InsertLeave" }, {
+ callback = function()
+ lint.try_lint()
+ end,
+ })
+ end,
+ })
+ use({
+ "stevearc/conform.nvim",
+ config = function()
+ require("conform").setup({
+ formatters_by_ft = {
+ c = { "clang-format", "trim_newlines", "twim_whitespace" },
+ json = { "jq", "trim_newlines", "twim_whitespace" },
+ lua = { "stylua", "trim_newlines", "twim_whitespace" },
+ nix = { "alejandra", "trim_newlines", "twim_whitespace" },
+ python = { "isort", "black", "trim_newlines", "twim_whitespace" },
+ sh = { "shfmt", "trim_newlines", "twim_whitespace" },
+ yaml = { "yq", "trim_newlines", "twim_whitespace" },
+ },
+ })
+ end,
+ })
use("SirVer/ultisnips")
use("honza/vim-snippets")
use("craigemery/vim-autotag")
use("scrooloose/nerdcommenter")
- -- Movement, format and others
+ -- Movement, format and others ---------------------------------------------
use("tpope/vim-surround")
use("tpope/vim-repeat")
use("dhruvasagar/vim-table-mode")
+ -- Filetypes ---------------------------------------------------------------
+ use("tmhedberg/SimpylFold")
+ use("LnL7/vim-nix")
+ use("kaarmu/typst.vim")
+ use("aliou/bats.vim")
- -- 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",
- "markdown_inline",
- "meson",
- "ninja",
- "ini",
- "gitcommit",
- "git_rebase",
- "git_config",
- "nix",
- "python",
- "toml",
- "vim",
- "vimdoc",
- "yaml",
- },
- highlight = {
- enable = true,
- -- TODO why we must set this to true?
- additional_vim_regex_highlighting = true,
- },
- })
-
- -- LSP
+ -- LSP ---------------------------------------------------------------------
local lspconfig = require("lspconfig")
lspconfig.clangd.setup({})
- lspconfig.rnix.setup({})
+ lspconfig.nil_ls.setup({})
lspconfig.pylsp.setup({})
lspconfig.bashls.setup({})
-
- -- Telescope
- require("mytelescope")
-
- -- Gitlab
- require("diffview").setup()
- require("gitlab").setup()
end)