From dc6d71b5b142bdbffe540f4e4559abdb47e5780a Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Sun, 15 Jan 2023 16:50:02 +0100 Subject: [PATCH] neovim overhaul (#1) It is a complete redo of the vim/nvim experience. It's neovim with lua everything While this was configured this way with a local computer in mind it should be easy to set up and use on a remote machine. Known Issues: * Fuzzy finder (this is down to me not having understood properly) * Harpoon adding paths (again me) * Need to review the `set.lua` and `remap.lua` for a more uniform approach in nomenclature. This should see more updates. Reviewed-on: https://git.com.de/pratyush/.cfg/pulls/1 --- .config/nvim/after/plugin/colors.lua | 11 +++++ .config/nvim/after/plugin/fugitive.lua | 1 + .config/nvim/after/plugin/harpoon.lua | 9 +++++ .config/nvim/after/plugin/lsp.lua | 6 +++ .config/nvim/after/plugin/telescope.lua | 8 ++++ .config/nvim/after/plugin/treesitter.lua | 26 ++++++++++++ .config/nvim/after/plugin/undotree.lua | 1 + .config/nvim/init.lua | 2 + .config/nvim/init.vim | 17 -------- .config/nvim/lua/mogad0n/init.lua | 2 + .config/nvim/lua/mogad0n/packer.lua | 51 ++++++++++++++++++++++++ .config/nvim/lua/mogad0n/remap.lua | 2 + .config/nvim/lua/mogad0n/set.lua | 36 +++++++++++++++++ 13 files changed, 155 insertions(+), 17 deletions(-) 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/harpoon.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 create mode 100644 .config/nvim/init.lua delete mode 100644 .config/nvim/init.vim create mode 100644 .config/nvim/lua/mogad0n/init.lua create mode 100644 .config/nvim/lua/mogad0n/packer.lua create mode 100644 .config/nvim/lua/mogad0n/remap.lua create mode 100644 .config/nvim/lua/mogad0n/set.lua diff --git a/.config/nvim/after/plugin/colors.lua b/.config/nvim/after/plugin/colors.lua new file mode 100644 index 0000000..7efdfb8 --- /dev/null +++ b/.config/nvim/after/plugin/colors.lua @@ -0,0 +1,11 @@ + +function ColorMyPencils(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) + + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) + +end + +ColorMyPencils() diff --git a/.config/nvim/after/plugin/fugitive.lua b/.config/nvim/after/plugin/fugitive.lua new file mode 100644 index 0000000..80c9070 --- /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/harpoon.lua b/.config/nvim/after/plugin/harpoon.lua new file mode 100644 index 0000000..ea87efc --- /dev/null +++ b/.config/nvim/after/plugin/harpoon.lua @@ -0,0 +1,9 @@ +local mark = require("harpoon.mark") +local ui = require("harpoon.ui") + +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "", function() ui.nav_file(1) end) +vim.keymap.set("n", "", function() ui.nav_file(2) end) +vim.keymap.set("n", "", function() ui.nav_file(3) end) +vim.keymap.set("n", "", function() ui.nav_file(4) end) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..72a70a3 --- /dev/null +++ b/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,6 @@ +-- Learn the keybindings, see :help lsp-zero-keybindings +-- Learn to configure LSP servers, see :help lsp-zero-api-showcase +local lsp = require('lsp-zero') +lsp.preset('recommended') + +lsp.setup() diff --git a/.config/nvim/after/plugin/telescope.lua b/.config/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..15c2655 --- /dev/null +++ b/.config/nvim/after/plugin/telescope.lua @@ -0,0 +1,8 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set('n', '', builtin.git_files, {}) +-- vim.keymap.set('n', 'fb', builtin.buffers, {}) +-- vim.keymap.set('n', 'fh', builtin.help_tags, {}) +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..84c16b6 --- /dev/null +++ b/.config/nvim/after/plugin/treesitter.lua @@ -0,0 +1,26 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the four listed parsers should always be installed) + ensure_installed = { "c", "python", "rust", "go", "javascript", "lua", "vim", "help" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + -- `false` will disable the whole extension + enable = true, + + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + 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..b6b9276 --- /dev/null +++ b/.config/nvim/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua new file mode 100644 index 0000000..2fe73e8 --- /dev/null +++ b/.config/nvim/init.lua @@ -0,0 +1,2 @@ +require("mogad0n") + diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim deleted file mode 100644 index a775675..0000000 --- a/.config/nvim/init.vim +++ /dev/null @@ -1,17 +0,0 @@ -set pastetoggle= -set -call plug#begin('~/.local/share/nvim/plugged') - -Plug 'liuchengxu/graphviz.vim' -Plug 'tpope/vim-fugitive' -Plug 'tpope/vim-surround' -Plug 'scrooloose/nerdtree' -Plug 'vim-airline/vim-airline' -Plug 'scrooloose/syntastic' -Plug 'scrooloose/nerdcommenter' -Plug 'valloric/youcompleteme' -Plug 'honza/vim-snippets' -Plug 'tomasr/molokai' -Plug 'tpope/vim-commentary' - -call plug#end() diff --git a/.config/nvim/lua/mogad0n/init.lua b/.config/nvim/lua/mogad0n/init.lua new file mode 100644 index 0000000..0096b8c --- /dev/null +++ b/.config/nvim/lua/mogad0n/init.lua @@ -0,0 +1,2 @@ +require("mogad0n.set") +require("mogad0n.remap") diff --git a/.config/nvim/lua/mogad0n/packer.lua b/.config/nvim/lua/mogad0n/packer.lua new file mode 100644 index 0000000..2a89c5f --- /dev/null +++ b/.config/nvim/lua/mogad0n/packer.lua @@ -0,0 +1,51 @@ +-- This file can be loaded by calling `lua require('plugins')` from your init.vim + +-- Only required if you have packer configured as `opt` +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.0', + -- or , branch = '0.1.x', + requires = { {'nvim-lua/plenary.nvim'} } + } + + use({ + 'rose-pine/neovim', + as = 'rose-pine', + config = function() + vim.cmd('colorscheme rose-pine') + end + }) + + use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) + use('nvim-treesitter/playground') + use('theprimeagen/harpoon') + use('mbbill/undotree') + use('tpope/vim-fugitive') + use { + 'VonHeikemen/lsp-zero.nvim', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'saadparwaiz1/cmp_luasnip'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + + -- Snippets + {'L3MON4D3/LuaSnip'}, + -- Snippet Collection (Optional) + {'rafamadriz/friendly-snippets'}, + } + } +end) diff --git a/.config/nvim/lua/mogad0n/remap.lua b/.config/nvim/lua/mogad0n/remap.lua new file mode 100644 index 0000000..b760350 --- /dev/null +++ b/.config/nvim/lua/mogad0n/remap.lua @@ -0,0 +1,2 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) diff --git a/.config/nvim/lua/mogad0n/set.lua b/.config/nvim/lua/mogad0n/set.lua new file mode 100644 index 0000000..0b0c091 --- /dev/null +++ b/.config/nvim/lua/mogad0n/set.lua @@ -0,0 +1,36 @@ +vim.opt.guicursor = "" +vim.opt.nu = true +vim.opt.relativenumber = true +vim.opt.errorbells = false + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + + +-- Give more space for displaying messages. +vim.opt.cmdheight = 1 + +-- Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable +-- delays and poor user experience. +vim.opt.updatetime = 50 + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.termguicolors = true + + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = "80" + +vim.g.mapleader = " " +