From 24fc98bfaca3f07c90ff33a3bfeb738fd84ff79a Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Tue, 12 Sep 2023 12:16:31 +0200 Subject: nvim: Add extensive Neovim configuration --- .config/nvim/after/plugin/colors.lua | 11 +++++++++ .config/nvim/after/plugin/fugitive.lua | 1 + .config/nvim/after/plugin/gsp.lua | 3 +++ .config/nvim/after/plugin/lsp.lua | 40 ++++++++++++++++++++++++++++++++ .config/nvim/after/plugin/telescope.lua | 8 +++++++ .config/nvim/after/plugin/treesitter.lua | 23 ++++++++++++++++++ .config/nvim/after/plugin/undotree.lua | 1 + 7 files changed, 87 insertions(+) create mode 100644 .config/nvim/after/plugin/colors.lua create mode 100644 .config/nvim/after/plugin/fugitive.lua create mode 100644 .config/nvim/after/plugin/gsp.lua create mode 100644 .config/nvim/after/plugin/lsp.lua create mode 100644 .config/nvim/after/plugin/telescope.lua create mode 100644 .config/nvim/after/plugin/treesitter.lua create mode 100644 .config/nvim/after/plugin/undotree.lua (limited to '.config/nvim/after/plugin') diff --git a/.config/nvim/after/plugin/colors.lua b/.config/nvim/after/plugin/colors.lua new file mode 100644 index 0000000..654b217 --- /dev/null +++ b/.config/nvim/after/plugin/colors.lua @@ -0,0 +1,11 @@ +require('rose-pine').setup({ + disable_background = true +}) + +function SetTheme(color) + vim.cmd.colorscheme(color or 'rose-pine') + vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' }) + vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' }) +end + +SetTheme() diff --git a/.config/nvim/after/plugin/fugitive.lua b/.config/nvim/after/plugin/fugitive.lua new file mode 100644 index 0000000..6e1b92d --- /dev/null +++ b/.config/nvim/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set('n', 'gs', vim.cmd.Git) diff --git a/.config/nvim/after/plugin/gsp.lua b/.config/nvim/after/plugin/gsp.lua new file mode 100644 index 0000000..4a52958 --- /dev/null +++ b/.config/nvim/after/plugin/gsp.lua @@ -0,0 +1,3 @@ +local lib = require('mango.lib') + +lib.setTabWidth(2, true) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..6891256 --- /dev/null +++ b/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,40 @@ +local lsp = require('lsp-zero') + +lsp.preset('recommended') +lsp.ensure_installed({ + 'clangd', + 'gopls', + 'rust_analyzer', +}) + +lsp.nvim_workspace() + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} +local cmp_mappings = lsp.defaults.cmp_mappings({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), +}) + +lsp.set_preferences({ + suggest_lsp_servers = false, + sign_icons = { } +}) + +lsp.setup_nvim_cmp({ + mapping = cmp_mappings +}) + +lsp.on_attach(function(_, bufnr) + local opts = {buffer = bufnr, remap = false} + + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'la', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'lr', vim.lsp.buf.rename, opts) + vim.keymap.set('n', 'l=', vim.lsp.buf.format, opts) + vim.keymap.set('i', '', vim.lsp.buf.signature_help, opts) +end) + +lsp.setup() diff --git a/.config/nvim/after/plugin/telescope.lua b/.config/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..a9d9225 --- /dev/null +++ b/.config/nvim/after/plugin/telescope.lua @@ -0,0 +1,8 @@ +local builtin = require('telescope.builtin') + +--vim.keymap.set('n', 'pf', builtin.git_files, {}) + +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input('Grep > ') }) +end) diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..ad7f027 --- /dev/null +++ b/.config/nvim/after/plugin/treesitter.lua @@ -0,0 +1,23 @@ +require('nvim-treesitter.configs').setup { + ensure_installed = { + 'c', + 'go', + 'gomod', + 'html', + 'lua', + 'python', + 'query', + 'rust', + 'vim', + 'vimdoc', + 'zig', + }, + + sync_install = false, + auto_install = true, + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} diff --git a/.config/nvim/after/plugin/undotree.lua b/.config/nvim/after/plugin/undotree.lua new file mode 100644 index 0000000..a346462 --- /dev/null +++ b/.config/nvim/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) -- cgit v1.2.3