add lots of neovim config

This commit is contained in:
nixos 2023-09-11 17:28:30 +02:00
parent 9e75af3939
commit 849d209774
2 changed files with 73 additions and 2 deletions

View file

@ -7,6 +7,7 @@
packages = with pkgs; [
keepassxc
nil
];
};
@ -19,7 +20,11 @@
vimdiffAlias = true;
defaultEditor = true;
plugins = with pkgs.vimPlugins; [
mason-nvim
nvim-lspconfig
gruvbox-nvim
leap-nvim
telescope-nvim
vim-commentary
];
extraLuaConfig = builtins.readFile ./neovim.lua;
};

View file

@ -1 +1,67 @@
require("mason").setup()
--[ GLOBAL ]--
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])
vim.g.mapleader = ";"
vim.o.signcolumn = "yes"
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.cursorline = true
--[ LSPCONFIG ]--
local opts = { noremap=true, silent=true }
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', '<leader>D', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', '<leader>d', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', '<leader>h', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', '<leader>i', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<leader>s', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>c', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', '<leader>fmt', function() vim.lsp.buf.format { async = true } end, bufopts)
end
require'lspconfig'.nil_ls.setup{ on_attach = on_attach }
--[ LEAP ]--
require('leap').add_default_mappings()
-- Don't remap 'x' in visual mode.
vim.keymap.del({'x', 'o'}, 'x')
vim.keymap.del({'x', 'o'}, 'X')
--[ TELESCOPE ]--
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>fs', builtin.lsp_document_symbols, {})
require('telescope').setup{
pickers = {
find_files = {
theme = "dropdown"
},
live_grep = {
theme = "dropdown"
},
buffers = {
theme = "dropdown"
},
lsp_references = {
theme = "dropdown"
},
lsp_document_symbols = {
theme = "dropdown"
}
}
}
--[ COMMENTARY ]--
vim.cmd([[autocmd FileType nix setlocal commentstring=#\ %s]])