From 811747b11ce60c8ccdd92e6b99688c2dafcdba5a Mon Sep 17 00:00:00 2001 From: Hans Goor Date: Wed, 27 Mar 2024 19:16:39 +0100 Subject: [PATCH] Add neovim config --- nvim/nvim/after/plugin/autopairs.lua | 1 + nvim/nvim/after/plugin/blamer.vim | 1 + nvim/nvim/after/plugin/indent-o-matic.lua | 10 ++ nvim/nvim/after/plugin/lsp.lua | 20 +++ nvim/nvim/after/plugin/nvim-tree.lua | 9 + nvim/nvim/after/plugin/telescope.lua | 7 + nvim/nvim/after/plugin/treesitter.lua | 27 +++ nvim/nvim/after/plugin/undotree.lua | 1 + nvim/nvim/init.lua | 1 + nvim/nvim/lua/eyedevelop/init.lua | 5 + nvim/nvim/lua/eyedevelop/packer.lua | 105 ++++++++++++ nvim/nvim/lua/eyedevelop/remap.lua | 4 + nvim/nvim/lua/eyedevelop/settings.lua | 37 +++++ nvim/nvim/lua/eyedevelop/theme.lua | 20 +++ nvim/nvim/plugin/packer_compiled.lua | 194 ++++++++++++++++++++++ 15 files changed, 442 insertions(+) create mode 100644 nvim/nvim/after/plugin/autopairs.lua create mode 100644 nvim/nvim/after/plugin/blamer.vim create mode 100644 nvim/nvim/after/plugin/indent-o-matic.lua create mode 100644 nvim/nvim/after/plugin/lsp.lua create mode 100644 nvim/nvim/after/plugin/nvim-tree.lua create mode 100644 nvim/nvim/after/plugin/telescope.lua create mode 100644 nvim/nvim/after/plugin/treesitter.lua create mode 100644 nvim/nvim/after/plugin/undotree.lua create mode 100644 nvim/nvim/init.lua create mode 100644 nvim/nvim/lua/eyedevelop/init.lua create mode 100644 nvim/nvim/lua/eyedevelop/packer.lua create mode 100644 nvim/nvim/lua/eyedevelop/remap.lua create mode 100644 nvim/nvim/lua/eyedevelop/settings.lua create mode 100644 nvim/nvim/lua/eyedevelop/theme.lua create mode 100644 nvim/nvim/plugin/packer_compiled.lua diff --git a/nvim/nvim/after/plugin/autopairs.lua b/nvim/nvim/after/plugin/autopairs.lua new file mode 100644 index 0000000..ba62d44 --- /dev/null +++ b/nvim/nvim/after/plugin/autopairs.lua @@ -0,0 +1 @@ +require("nvim-autopairs").setup {} diff --git a/nvim/nvim/after/plugin/blamer.vim b/nvim/nvim/after/plugin/blamer.vim new file mode 100644 index 0000000..72ad485 --- /dev/null +++ b/nvim/nvim/after/plugin/blamer.vim @@ -0,0 +1 @@ +let g:blamer_enabled = 1 diff --git a/nvim/nvim/after/plugin/indent-o-matic.lua b/nvim/nvim/after/plugin/indent-o-matic.lua new file mode 100644 index 0000000..093de12 --- /dev/null +++ b/nvim/nvim/after/plugin/indent-o-matic.lua @@ -0,0 +1,10 @@ +require('indent-o-matic').setup { + -- Number of lines without indentation before giving up. + max_lines = 2048, + + -- Space indentation defaults. + standard_widths = { 2, 4, 8 }, + + -- Skip multi line comments and strings. + skip_multiline = true, +} diff --git a/nvim/nvim/after/plugin/lsp.lua b/nvim/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..47165c3 --- /dev/null +++ b/nvim/nvim/after/plugin/lsp.lua @@ -0,0 +1,20 @@ +local lsp = require("lsp-zero") + +lsp.on_attach(function(_client, _bufnr) + lsp.default_keymaps({bufnr = _bufnr}) +end) + +require("mason").setup({}) +require("mason-lspconfig").setup({ + ensure_installed = {}, + handlers = { + lsp.default_setup, + }, +}) + +local cmp = require("cmp") +cmp.setup({ + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.confirm({select = false}), + }), +}) diff --git a/nvim/nvim/after/plugin/nvim-tree.lua b/nvim/nvim/after/plugin/nvim-tree.lua new file mode 100644 index 0000000..d4af864 --- /dev/null +++ b/nvim/nvim/after/plugin/nvim-tree.lua @@ -0,0 +1,9 @@ +-- Disable netrw at nvim start. +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 + +-- Set term gui colours +vim.opt.termguicolors = true + +-- Use defaults +require('nvim-tree').setup() diff --git a/nvim/nvim/after/plugin/telescope.lua b/nvim/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..aa90eeb --- /dev/null +++ b/nvim/nvim/after/plugin/telescope.lua @@ -0,0 +1,7 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.git_files, {}) +vim.keymap.set('n', 'fF', builtin.find_files, {}) +vim.keymap.set('n', 'fG', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fc', builtin.commands, {}) +vim.keymap.set('n', 'fC', builtin.colorscheme, {}) diff --git a/nvim/nvim/after/plugin/treesitter.lua b/nvim/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..380857b --- /dev/null +++ b/nvim/nvim/after/plugin/treesitter.lua @@ -0,0 +1,27 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "go", "bash", "javascript", "typescript", "rust", "graphql" }, + + -- 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 = { + enable = true, + + -- 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, + }, + + -- Indentation is disabled by default. + -- enable it. + indent = { + enable = true, + }, +} diff --git a/nvim/nvim/after/plugin/undotree.lua b/nvim/nvim/after/plugin/undotree.lua new file mode 100644 index 0000000..62262a8 --- /dev/null +++ b/nvim/nvim/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set('n', 'cu', vim.cmd.UndotreeToggle) diff --git a/nvim/nvim/init.lua b/nvim/nvim/init.lua new file mode 100644 index 0000000..93f9674 --- /dev/null +++ b/nvim/nvim/init.lua @@ -0,0 +1 @@ +require("eyedevelop") diff --git a/nvim/nvim/lua/eyedevelop/init.lua b/nvim/nvim/lua/eyedevelop/init.lua new file mode 100644 index 0000000..8fb9139 --- /dev/null +++ b/nvim/nvim/lua/eyedevelop/init.lua @@ -0,0 +1,5 @@ +require('eyedevelop.packer') +require('eyedevelop.remap') +require('eyedevelop.theme') +require('eyedevelop.settings') + diff --git a/nvim/nvim/lua/eyedevelop/packer.lua b/nvim/nvim/lua/eyedevelop/packer.lua new file mode 100644 index 0000000..3f9ca94 --- /dev/null +++ b/nvim/nvim/lua/eyedevelop/packer.lua @@ -0,0 +1,105 @@ +-- This file can be loaded by calling `lua require("plugins")` from your init.vim + +-- Bootstrap packer +local ensure_packer = function() + local packer_path = vim.fn.stdpath('data') .. 'site/pack/packer/start/packer.nvim' + if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then + print('Installing Packer...') + vim.fn.system({ + 'git', + 'clone', + '--depth=1', + 'https://github.com/wbthomason/packer.nvim', + packer_path + }) + vim.cmd [[packadd packer.nvim]] + return true + else + return false + end +end + +local packer_bootstrap = ensure_packer() + +return require("packer").startup(function(use) + -- Packer can manage itself + use "wbthomason/packer.nvim" + + -- Fuzzy finder + use { + "nvim-telescope/telescope.nvim", tag = "0.1.6", + requires = { { "nvim-lua/plenary.nvim" } } + } + + -- Colour theme + use { + "rose-pine/neovim", tag = "v3.0.1", + } + + -- TreeSitter + use { + "nvim-treesitter/nvim-treesitter", tag = "v0.9.2", + run = function() + local ts_update = require("nvim-treesitter.install").update({ with_sync = true }) + ts_update() + end, + } + + -- UndoTree + use { + "mbbill/undotree", tag = "rel_6.1", + } + + -- LSP + use { + "VonHeikemen/lsp-zero.nvim", + branch = "v3.x", + requires = { + -- LSP Support + { "neovim/nvim-lspconfig" }, + { "williamboman/mason.nvim" }, + { "williamboman/mason-lspconfig.nvim" }, + + -- Autocompletion + { "hrsh7th/nvim-cmp" }, + { "hrsh7th/cmp-nvim-lsp" }, + { "L3MON4D3/LuaSnip" }, + } + } + + -- File manager + use { + "nvim-tree/nvim-tree.lua", tag = "v1.2", + } + use { + "nvim-tree/nvim-web-devicons" + } + + -- Git BLAME + use { + "APZelos/blamer.nvim", tag = "v1.3.0", + } + + -- Tab support + use { + "romgrk/barbar.nvim", tag = "v1.7.0", + requires = { + { "lewis6991/gitsigns.nvim" }, -- Git status + { "nvim-tree/nvim-web-devicons" }, -- Icons + } + } + + -- Automatically set indent values + use { + "Darazaki/indent-o-matic" + } + + -- Auto match brackets. + use { + "windwp/nvim-autopairs", + } + + if packer_bootstrap then + require("packer").sync() + end +end) diff --git a/nvim/nvim/lua/eyedevelop/remap.lua b/nvim/nvim/lua/eyedevelop/remap.lua new file mode 100644 index 0000000..c71e200 --- /dev/null +++ b/nvim/nvim/lua/eyedevelop/remap.lua @@ -0,0 +1,4 @@ +vim.g.mapleader = ' ' + +vim.keymap.set('n', 'q', vim.cmd.bd, {}) +vim.keymap.set('n', 'fv', vim.cmd.NvimTreeToggle, {}) diff --git a/nvim/nvim/lua/eyedevelop/settings.lua b/nvim/nvim/lua/eyedevelop/settings.lua new file mode 100644 index 0000000..04ed2c5 --- /dev/null +++ b/nvim/nvim/lua/eyedevelop/settings.lua @@ -0,0 +1,37 @@ +-- Line numbers +vim.opt.nu = true +vim.opt.relativenumber = true + +-- Indent settings +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true + +-- No line wrap +vim.opt.wrap = false + +-- Undo for greater times +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv('HOME') .. '/.local/share/nvim/undodir' +vim.opt.undofile = true + +-- No highlighting for search +vim.opt.hlsearch = false +vim.opt.incsearch = true + +-- Colours +vim.opt.termguicolors = true + +-- Scrolling +vim.opt.scrolloff = 15 +vim.opt.signcolumn = 'yes' +vim.opt.isfname:append('@-@') + +-- Fast updates +vim.opt.updatetime = 50 + +-- Colour columns +vim.opt.colorcolumn = '120' diff --git a/nvim/nvim/lua/eyedevelop/theme.lua b/nvim/nvim/lua/eyedevelop/theme.lua new file mode 100644 index 0000000..68d3de5 --- /dev/null +++ b/nvim/nvim/lua/eyedevelop/theme.lua @@ -0,0 +1,20 @@ +require('rose-pine').setup({ + variant = "main", + dark_variant = "main", + dim_inactive_windows = false, + extend_background_behind_borders = true, + + enable = { + terminal = true, + legacy_highlights = false, + migrations = true, + }, + + styles = { + bold = true, + italic = true, + transparency = false, + } +}) + +vim.cmd("colorscheme rose-pine") diff --git a/nvim/nvim/plugin/packer_compiled.lua b/nvim/nvim/plugin/packer_compiled.lua new file mode 100644 index 0000000..5aff23a --- /dev/null +++ b/nvim/nvim/plugin/packer_compiled.lua @@ -0,0 +1,194 @@ +-- Automatically generated packer.nvim plugin loader code + +if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then + vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"') + return +end + +vim.api.nvim_command('packadd packer.nvim') + +local no_errors, error_msg = pcall(function() + +_G._packer = _G._packer or {} +_G._packer.inside_compile = true + +local time +local profile_info +local should_profile = false +if should_profile then + local hrtime = vim.loop.hrtime + profile_info = {} + time = function(chunk, start) + if start then + profile_info[chunk] = hrtime() + else + profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6 + end + end +else + time = function(chunk, start) end +end + +local function save_profiles(threshold) + local sorted_times = {} + for chunk_name, time_taken in pairs(profile_info) do + sorted_times[#sorted_times + 1] = {chunk_name, time_taken} + end + table.sort(sorted_times, function(a, b) return a[2] > b[2] end) + local results = {} + for i, elem in ipairs(sorted_times) do + if not threshold or threshold and elem[2] > threshold then + results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms' + end + end + if threshold then + table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)') + end + + _G._packer.profile_output = results +end + +time([[Luarocks path setup]], true) +local package_path_str = "/home/eyedevelop/.cache/nvim/packer_hererocks/2.1.1707061634/share/lua/5.1/?.lua;/home/eyedevelop/.cache/nvim/packer_hererocks/2.1.1707061634/share/lua/5.1/?/init.lua;/home/eyedevelop/.cache/nvim/packer_hererocks/2.1.1707061634/lib/luarocks/rocks-5.1/?.lua;/home/eyedevelop/.cache/nvim/packer_hererocks/2.1.1707061634/lib/luarocks/rocks-5.1/?/init.lua" +local install_cpath_pattern = "/home/eyedevelop/.cache/nvim/packer_hererocks/2.1.1707061634/lib/lua/5.1/?.so" +if not string.find(package.path, package_path_str, 1, true) then + package.path = package.path .. ';' .. package_path_str +end + +if not string.find(package.cpath, install_cpath_pattern, 1, true) then + package.cpath = package.cpath .. ';' .. install_cpath_pattern +end + +time([[Luarocks path setup]], false) +time([[try_loadstring definition]], true) +local function try_loadstring(s, component, name) + local success, result = pcall(loadstring(s), name, _G.packer_plugins[name]) + if not success then + vim.schedule(function() + vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {}) + end) + end + return result +end + +time([[try_loadstring definition]], false) +time([[Defining packer_plugins]], true) +_G.packer_plugins = { + LuaSnip = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/LuaSnip", + url = "https://github.com/L3MON4D3/LuaSnip" + }, + ["barbar.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/barbar.nvim", + url = "https://github.com/romgrk/barbar.nvim" + }, + ["blamer.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/blamer.nvim", + url = "https://github.com/APZelos/blamer.nvim" + }, + ["cmp-nvim-lsp"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp", + url = "https://github.com/hrsh7th/cmp-nvim-lsp" + }, + ["gitsigns.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/gitsigns.nvim", + url = "https://github.com/lewis6991/gitsigns.nvim" + }, + ["indent-o-matic"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/indent-o-matic", + url = "https://github.com/Darazaki/indent-o-matic" + }, + ["lsp-zero.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/lsp-zero.nvim", + url = "https://github.com/VonHeikemen/lsp-zero.nvim" + }, + ["mason-lspconfig.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim", + url = "https://github.com/williamboman/mason-lspconfig.nvim" + }, + ["mason.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/mason.nvim", + url = "https://github.com/williamboman/mason.nvim" + }, + neovim = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/neovim", + url = "https://github.com/rose-pine/neovim" + }, + ["nvim-autopairs"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/nvim-autopairs", + url = "https://github.com/windwp/nvim-autopairs" + }, + ["nvim-cmp"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/nvim-cmp", + url = "https://github.com/hrsh7th/nvim-cmp" + }, + ["nvim-lspconfig"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/nvim-lspconfig", + url = "https://github.com/neovim/nvim-lspconfig" + }, + ["nvim-tree.lua"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/nvim-tree.lua", + url = "https://github.com/nvim-tree/nvim-tree.lua" + }, + ["nvim-treesitter"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/nvim-treesitter", + url = "https://github.com/nvim-treesitter/nvim-treesitter" + }, + ["nvim-web-devicons"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/nvim-web-devicons", + url = "https://github.com/nvim-tree/nvim-web-devicons" + }, + ["packer.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/packer.nvim", + url = "https://github.com/wbthomason/packer.nvim" + }, + ["plenary.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/plenary.nvim", + url = "https://github.com/nvim-lua/plenary.nvim" + }, + ["telescope.nvim"] = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/telescope.nvim", + url = "https://github.com/nvim-telescope/telescope.nvim" + }, + undotree = { + loaded = true, + path = "/home/eyedevelop/.local/share/nvim/site/pack/packer/start/undotree", + url = "https://github.com/mbbill/undotree" + } +} + +time([[Defining packer_plugins]], false) + +_G._packer.inside_compile = false +if _G._packer.needs_bufread == true then + vim.cmd("doautocmd BufRead") +end +_G._packer.needs_bufread = false + +if should_profile then save_profiles() end + +end) + +if not no_errors then + error_msg = error_msg:gsub('"', '\\"') + vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None') +end