From e7e79986addcc7b4c49d2674ecd2b53b14280781 Mon Sep 17 00:00:00 2001 From: Asmir A Date: Sat, 8 Jul 2023 22:09:45 +0200 Subject: [PATCH] vim: update and cleanup --- home/vimrc.lua | 34 ++++++++++++++++++++++------------ home/vimrc.nix | 17 +++++++++++++++-- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/home/vimrc.lua b/home/vimrc.lua index 1c5abe0..492d12a 100644 --- a/home/vimrc.lua +++ b/home/vimrc.lua @@ -19,19 +19,7 @@ vim.wo.number = true vim.cmd([[colorscheme gruvbox]]) --- Defines a read-write directory for treesitters in nvim's cache dir -local parser_install_dir = vim.fn.stdpath("cache") .. "/treesitters" -if vim.fn.isdirectory(parser_install_dir) == 0 then - vim.fn.mkdir(parser_install_dir, "p") -end --- Adding runtime needed for Nix setup on non NixOS -vim.o.runtimepath = vim.o.runtimepath .. "," .. parser_install_dir - -require 'nvim-treesitter.install'.compilers = { 'gcc' } - require 'nvim-treesitter.configs'.setup { - ensure_installed = { "c", "cpp", "zig", "python", "verilog", "nix", "lua", "latex" }, - parser_install_dir = parser_install_dir, highlight = { enable = true, disable = {} }, indent = { enable = false, disable = {} }, rainbow = { @@ -60,6 +48,7 @@ vim.api.nvim_set_keymap('n', '', '', opts) vim.api.nvim_set_keymap('n', '', '', opts) vim.api.nvim_set_keymap('n', '', '', opts) vim.api.nvim_set_keymap('n', '', '', opts) +vim.api.nvim_set_keymap('n', "", "lua require('fzf-lua').files()", opts) vim.api.nvim_create_autocmd('LspAttach', { desc = 'LSP actions', @@ -110,6 +99,27 @@ vim.api.nvim_create_autocmd('LspAttach', { end }) +vim.diagnostic.config({ + virtual_text = false, -- Turn off inline diagnostics +}) +-- Show all diagnostics on current line in floating window +vim.api.nvim_set_keymap( + 'n', 'd', ':lua vim.diagnostic.open_float()', + { noremap = true, silent = true } +) +-- Go to next diagnostic (if there are multiple on the same line, only shows +-- one at a time in the floating window) +vim.api.nvim_set_keymap( + 'n', 'n', ':lua vim.diagnostic.goto_next()', + { noremap = true, silent = true } +) +-- Go to prev diagnostic (if there are multiple on the same line, only shows +-- one at a time in the floating window) +vim.api.nvim_set_keymap( + 'n', 'p', ':lua vim.diagnostic.goto_prev()', + { noremap = true, silent = true } +) + -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local cmp = require 'cmp' diff --git a/home/vimrc.nix b/home/vimrc.nix index 6256394..790b1bb 100644 --- a/home/vimrc.nix +++ b/home/vimrc.nix @@ -19,6 +19,20 @@ ]; plugins = with pkgs.vimPlugins; [ + (nvim-treesitter.withPlugins (parsers: [ + parsers.c + parsers.cpp + parsers.json + parsers.latex + parsers.lua + parsers.nix + parsers.python + parsers.query + parsers.rust + parsers.verilog + parsers.vimdoc + parsers.zig + ])) cmp-buffer cmp-cmdline cmp-nvim-lsp @@ -26,11 +40,10 @@ cmp-path colorizer fugitive - fzf-vim + fzf-lua gruvbox nvim-cmp nvim-lspconfig - nvim-treesitter nvim-ts-rainbow repeat targets-vim