From 5a916f838aebeb577ed2bf8147edd8a6ef1236f5 Mon Sep 17 00:00:00 2001 From: BraydonKains Date: Mon, 22 May 2023 14:16:44 -0400 Subject: [PATCH] neovim setup stuff --- nvim/after/plugin/colours.lua | 13 +++++++++ nvim/after/plugin/fugitive.lua | 1 + nvim/after/plugin/lsp.lua | 38 ++++++++++++++++++++++++ nvim/after/plugin/telescope.lua | 11 +++++++ nvim/after/plugin/treesitter.lua | 27 +++++++++++++++++ nvim/after/plugin/undotree.lua | 1 + nvim/init.lua | 1 + nvim/lua/RageCage64/init.lua | 3 ++ nvim/lua/RageCage64/packer.lua | 50 ++++++++++++++++++++++++++++++++ nvim/lua/RageCage64/remap.lua | 48 ++++++++++++++++++++++++++++++ nvim/lua/RageCage64/set.lua | 25 ++++++++++++++++ nvim_setup.sh | 1 + 12 files changed, 219 insertions(+) create mode 100644 nvim/after/plugin/colours.lua create mode 100644 nvim/after/plugin/fugitive.lua create mode 100644 nvim/after/plugin/lsp.lua create mode 100644 nvim/after/plugin/telescope.lua create mode 100644 nvim/after/plugin/treesitter.lua create mode 100644 nvim/after/plugin/undotree.lua create mode 100644 nvim/init.lua create mode 100644 nvim/lua/RageCage64/init.lua create mode 100644 nvim/lua/RageCage64/packer.lua create mode 100644 nvim/lua/RageCage64/remap.lua create mode 100644 nvim/lua/RageCage64/set.lua create mode 100644 nvim_setup.sh diff --git a/nvim/after/plugin/colours.lua b/nvim/after/plugin/colours.lua new file mode 100644 index 0000000..2ad675b --- /dev/null +++ b/nvim/after/plugin/colours.lua @@ -0,0 +1,13 @@ +require("rose-pine").setup({ + variant = "moon" +}) + +function SetColour(colour) + colour = colour or "gruvbox" + vim.cmd(string.format("colorscheme %s", colour)) + + --vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + --vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +SetColour() diff --git a/nvim/after/plugin/fugitive.lua b/nvim/after/plugin/fugitive.lua new file mode 100644 index 0000000..80c9070 --- /dev/null +++ b/nvim/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git) diff --git a/nvim/after/plugin/lsp.lua b/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..386d131 --- /dev/null +++ b/nvim/after/plugin/lsp.lua @@ -0,0 +1,38 @@ +local lsp = require('lsp-zero') + +lsp.preset('recommended') + +require("mason-lspconfig").setup({ + ensure_installed = { + 'lua_ls', + 'gopls', + 'rust_analyzer', + 'cmake', + 'clangd', + 'zls', + 'bashls', + } +}) + +lsp.nvim_workspace() + +lsp.set_preferences({ + sign_icons = { } +}) + +lsp.on_attach(function(client, bufnr) + local opts = { buffer = bufnr, remap = false } + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "gh", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.buf.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + vim.keymap.set("n", "", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "rn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) +end) + +lsp.setup() diff --git a/nvim/after/plugin/telescope.lua b/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..8381f91 --- /dev/null +++ b/nvim/after/plugin/telescope.lua @@ -0,0 +1,11 @@ +local builtin = require('telescope.builtin') + +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fp', builtin.git_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +--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/nvim/after/plugin/treesitter.lua b/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..23de6b0 --- /dev/null +++ b/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", "go", "zig", "rust" }, + + -- 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, + + -- List of parsers to ignore installing (for "all") + ignore_install = { "javascript" }, + + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + + 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, + }, +} diff --git a/nvim/after/plugin/undotree.lua b/nvim/after/plugin/undotree.lua new file mode 100644 index 0000000..a346462 --- /dev/null +++ b/nvim/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set('n', 'u', vim.cmd.UndotreeToggle) diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..c87e8d0 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1 @@ +require("RageCage64") diff --git a/nvim/lua/RageCage64/init.lua b/nvim/lua/RageCage64/init.lua new file mode 100644 index 0000000..edaa10a --- /dev/null +++ b/nvim/lua/RageCage64/init.lua @@ -0,0 +1,3 @@ +require("RageCage64.remap") +require("RageCage64.packer") +require("RageCage64.set") diff --git a/nvim/lua/RageCage64/packer.lua b/nvim/lua/RageCage64/packer.lua new file mode 100644 index 0000000..0777410 --- /dev/null +++ b/nvim/lua/RageCage64/packer.lua @@ -0,0 +1,50 @@ +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + use 'wbthomason/packer.nvim' + + -- Navigation + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.1', + -- or , branch = '0.1.x', + requires = { {'nvim-lua/plenary.nvim'} } + } + + -- Colours + use("ellisonleao/gruvbox.nvim") + use({'rose-pine/neovim', as = 'rose-pine' }) + + -- Treesitter + use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) + use('nvim-treesitter/playground') + + -- Editing + use('mbbill/undotree') + use('tpope/vim-surround') + use('tpope/vim-commentary') + + -- LSP + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v2.x', + requires = { + -- LSP Support + {'neovim/nvim-lspconfig'}, -- Required + { -- Optional + 'williamboman/mason.nvim', + run = function() + vim.cmd [[MasonUpdate]] + end, + }, + {'williamboman/mason-lspconfig.nvim'}, -- Optional + + -- Autocompletion + {'hrsh7th/nvim-cmp'}, -- Required + {'hrsh7th/cmp-nvim-lsp'}, -- Required + {'L3MON4D3/LuaSnip'}, -- Required + }, + + use('tpope/vim-fugitive'), + use('editorconfig/editorconfig-vim'), +} +end) diff --git a/nvim/lua/RageCage64/remap.lua b/nvim/lua/RageCage64/remap.lua new file mode 100644 index 0000000..f1417e4 --- /dev/null +++ b/nvim/lua/RageCage64/remap.lua @@ -0,0 +1,48 @@ +vim.g.mapleader = " " + +vim.keymap.set("n", "pv", vim.cmd.Ex) + +-- Paste over without copying in the pasted over word +vim.keymap.set("x", "p", "\"_dP") + +-- From old vimrc + +-- Enter and space completion +local function enter_complete(seq) + local open_seq = string.sub(seq, 1, math.floor(string.len(seq)/2)) + local close_seq = string.sub(seq, math.ceil(string.len(seq)/2)+1, string.len(seq)) + vim.keymap.set( + "i", + string.format("%s", open_seq), + string.format("%s%sO", open_seq, close_seq) + ) +end + +local function space_complete(seq) + local open_seq = string.sub(seq, 1, string.len(seq)/2) + local lefts = string.rep("", string.len(seq)/2) + vim.keymap.set( + "i", + string.format("%s", open_seq), + string.format("%s%s", seq, lefts) + ) +end + +enter_complete("{}") +enter_complete("[]") +enter_complete("({})") + +space_complete("[]") +space_complete("()") +space_complete("<>") +space_complete("{}") +space_complete("({})") + +-- Split management +vim.keymap.set("n", "w", "") +vim.keymap.set("n", "ws", ":vsp") +vim.keymap.set("n", "wi", ":sp") +vim.keymap.set("n", "wt", ":tabnew") + +vim.keymap.set("n", "c", '"+') +vim.keymap.set("v", "c", '"+') diff --git a/nvim/lua/RageCage64/set.lua b/nvim/lua/RageCage64/set.lua new file mode 100644 index 0000000..2f9da0d --- /dev/null +++ b/nvim/lua/RageCage64/set.lua @@ -0,0 +1,25 @@ +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 diff --git a/nvim_setup.sh b/nvim_setup.sh new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/nvim_setup.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash