From f57c054aa07a38f7dc8eee9229f8a118663bb1d1 Mon Sep 17 00:00:00 2001 From: Harry Anderson Date: Sun, 5 Nov 2023 13:41:46 +1100 Subject: [PATCH] add old nvim bindings --- after/plugin/defaults.lua | 148 +++++++++++++++++++++++++++++++++++ after/plugin/keymaps.lua | 95 ++++++++++++++++++++++ init.lua | 26 +++--- lazy-lock.json | 34 ++++++++ lua/custom/plugins/harry.lua | 8 ++ 5 files changed, 301 insertions(+), 10 deletions(-) create mode 100644 after/plugin/defaults.lua create mode 100644 after/plugin/keymaps.lua create mode 100644 lazy-lock.json create mode 100644 lua/custom/plugins/harry.lua diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua new file mode 100644 index 00000000..e745f579 --- /dev/null +++ b/after/plugin/defaults.lua @@ -0,0 +1,148 @@ + +-- Settings +vim.opt.relativenumber = true +-- The backspace key has slightly unintuitive behavior by default. For example, +-- by default, you can't backspace before the insertion point set with 'i'. +-- This configuration makes backspace behave more reasonably, in that you can +-- backspace over anything. +vim.opt.backspace = { 'indent', 'eol', 'start' } +-- By default, Vim doesn't let you hide a buffer (i.e. have a buffer that isn't +-- shown in any window) that has unsaved changes. This is to prevent you from +-- forgetting about unsaved changes and then quitting e.g. via `:qa!`. We find +-- hidden buffers helpful enough to disable this protection. See `:help hidden` +-- for more information on this. +vim.opt.hidden = true +-- This setting makes search case-insensitive when all characters in the string +-- being searched are lowercase. However, the search becomes case-sensitive if +-- it contains any capital letters. This makes searching more convenient. +vim.opt.ignorecase = true +vim.opt.smartcase = true +-- Enable searching as you type, rather than waiting till you press enter. +vim.opt.incsearch = true +-- Unbind some useless/annoying default key bindings. +-- 'Q' in normal mode enters Ex mode. You almost never want this. +vim.keymap.set('n', 'Q', '', { noremap = true, silent = true }) +-- Tab settings +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.expandtab = true +-- Do smart autoindenting when starting a new line. +vim.opt.smartindent = true +vim.opt.shiftwidth = 4 +-- Always block cursor +vim.opt.guicursor = '' +-- Disable highlighted search matches +vim.opt.hlsearch = false +-- Disable swapfiles +vim.opt.swapfile = false +-- undo settings +vim.opt.undodir = vim.fn.expand('$HOME') .. '/nvim/undo' +vim.opt.undofile = true +-- Enables 24-bit RGB color +vim.opt.termguicolors = true +-- Scroll settings +vim.opt.scrolloff = 8 +-- Turn off -- INSERT -- message +vim.opt.showmode = false +-- Add column for hints to prevent gitter +vim.opt.signcolumn = 'yes' +-- Highlight current line of cursor +vim.opt.cursorline = true +-- Clipboard settings +-- ALWAYS use the clipboard for ALL operations (instead of interacting with +--the '+' and/or '*' registers explicitly) +-- vim.opt.clipboard = 'unnamedplus' +-- Wrappring settings +vim.opt.wrap = false +--global status line +vim.opt.laststatus = 3 + + +-- Colorscheme +-- https://github.com/projekt0n/github-nvim-theme +require("github-theme").setup({ + specs = { + all = { + diag = { + error = 'red', + hint = 'orange', + }, + } + }, + + groups = { + all = { + StatusLine = {link = "Comment"}, + Search = {link = "TSNote"}, + TSField = {} + } + } +}) +-- vim.cmd [[colorscheme github_dark_colorblind]] +vim.cmd.colorscheme('github_dark_colorblind') + + + + +-- Telescope config +-- mostly defaults pulled from the docs +local actions = require('telescope.actions') +require('telescope').setup{ + defaults = { + -- Default configuration for telescope goes here: + -- config_key = value, + sorting_strategy = "ascending", + -- winblend = 30, + layout_config = { + horizontal = { + prompt_position = "top", + width = 0.95, + height = 0.95 + } + }, + mappings = { + i = { + -- map actions.which_key to (default: ) + -- actions.which_key shows the mappings for your picker, + -- e.g. git_{create, delete, ...}_branch for the git_branches picker + [""] = actions.select_default, + } + } + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = false, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + } + }, +} +-- require('telescope').load_extension('fzf') +-- require('telescope').load_extension('dap') + +-- Emmet +-- C-y + , +vim.g.user_emmet_mode = 'n' +vim.g.user_emmet_leader_key = ',' +vim.g.user_emmet_settings = { + typescript = { + extends = 'jsx', + }, + typescriptreact = { + extends = 'jsx', + } +} + +vim.g.neoformat_try_node_exe = 1 + + +-- -- Show diagnostic popup on cursor hover +-- vim.g.updatetime = 300 +-- vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float()]] +-- +-- Rust format on save +vim.g.rustfmt_autosave = 1 +-- Filetype detection +vim.cmd('filetype plugin indent on') diff --git a/after/plugin/keymaps.lua b/after/plugin/keymaps.lua new file mode 100644 index 00000000..cb7d446d --- /dev/null +++ b/after/plugin/keymaps.lua @@ -0,0 +1,95 @@ +local opts = { noremap = true, silent = true } + +-- Keymaps +-- Paste over selection +vim.keymap.set('v', 'p', '"_dP', opts) +-- Y copy from cursor to end of line +vim.keymap.set('n', 'Y', 'y$', opts) +-- Keep cursor centered when scrolling search matches +vim.keymap.set('n', 'n', 'nzzzv', opts) +vim.keymap.set('n', 'N', 'Nzzzv', opts) +vim.keymap.set('n', 'J', 'mzJ`z', opts) +-- Undo breakpoints +vim.keymap.set('i', ',', ',u', opts) +vim.keymap.set('i', '.', '.u', opts) +vim.keymap.set('i', '!', '!u', opts) +vim.keymap.set('i', '?', '?u', opts) +-- Jumplist mutations +vim.keymap.set('n', ' k', '(v:count > 5 ? "m\'" . v:count : "") . \'k\'', opts) +vim.keymap.set('n', ' j', '(v:count > 5 ? "m\'" . v:count : "") . \'j\'', opts) +-- Moving text +vim.keymap.set('v', 'J', ':m \'>+1gv=gv', opts) +vim.keymap.set('v', 'K', ':m \'>-2gv=gv', opts) +vim.keymap.set('n', 'j', ':m .+1==', opts) +vim.keymap.set('n', 'k', ':m .-2==', opts) + +vim.keymap.set('n', 'ft', ':Format', opts) +-- GIT +-- Fugitive git bindings +vim.keymap.set('n', 'ga', ':Git add %:p', opts) +vim.keymap.set('n', 'gs', ':Git', opts) +vim.keymap.set('n', 'gc', ':Git commit -v -q', opts) +vim.keymap.set('n', 'gt', ':Git commit -v -q %:p', opts) +vim.keymap.set('n', 'd', ':Gdiff', opts) +vim.keymap.set('n', 'dm', ':Gdiffsplit!', opts) +vim.keymap.set('n', 'ge', ':Gedit', opts) +vim.keymap.set('n', 'gr', ':Gread', opts) +vim.keymap.set('n', 'gw', ':Gwrite', opts) +vim.keymap.set('n', 'gl', ':silent! Glog:bot copen', opts) +vim.keymap.set('n', 'gp', ':Ggrep', opts) +vim.keymap.set('n', 'gm', ':Gmove', opts) +vim.keymap.set('n', 'gb', ':Git branch', opts) +vim.keymap.set('n', 'go', ':Git checkout', opts) +vim.keymap.set('n', 'gps', ':Git push', opts) +vim.keymap.set('n', 'gpl', ':Dispatch! git pull', opts) +-- Interactive merge conflict SPAVE-mv to trigger from git status menu +vim.keymap.set('n', 'gj', ':diffget //3', opts) +vim.keymap.set('n', 'gf', ':diffget //2', opts) +-- TELESCOPE +vim.keymap.set('n', 'rg', require('telescope.builtin').live_grep, opts) +vim.keymap.set('n', 'pw', require('telescope.builtin').grep_string, opts) +vim.keymap.set('n', 'pf', require('telescope.builtin').find_files, opts) +vim.keymap.set('n', 'pg', require('telescope.builtin').git_files, opts) +vim.keymap.set('n', 'pb', require('telescope.builtin').buffers, opts) +vim.keymap.set('n', 'm', require('telescope.builtin').man_pages, opts) +vim.keymap.set('n', 'pc', require('telescope.builtin').current_buffer_fuzzy_find, opts) +vim.keymap.set('n', 'tg', require('telescope.builtin').live_grep, opts) +vim.keymap.set('n', 'gl', require('telescope.builtin').git_bcommits, opts) +vim.keymap.set('n', 'gk', require('telescope.builtin').git_commits, opts) +-- kenesis +vim.keymap.set('n', 'th', require('telescope.builtin').grep_string, opts) +vim.keymap.set('n', 'tj', require('telescope.builtin').find_files, opts) +vim.keymap.set('n', 'tk', require('telescope.builtin').git_files, opts) +vim.keymap.set('n', 'tm', require('telescope.builtin').buffers, opts) +vim.keymap.set('n', 't;', require('telescope.builtin').help_tags, opts) +vim.keymap.set('n', 'tl', require('telescope.builtin').current_buffer_fuzzy_find, opts) +-- for debugger +-- vim.keymap.set('n', 'tp', ':Telescope dap list_breakpoints', opts) +-- vim.keymap.set('n', 'tc', ':Telescope dap commands', opts) + +-- Harpoon +vim.keymap.set('n', 'ha', 'lua require("harpoon.mark").add_file()', opts) +vim.keymap.set('n', 'hj', 'lua require("harpoon.ui").toggle_quick_menu()', opts) +vim.keymap.set('n', 'hn', 'lua require("harpoon.ui").nav_next()', opts) +vim.keymap.set('n', 'hp', 'lua require("harpoon.ui").nav_prev()', opts) +vim.keymap.set('n', 'h1', 'lua require("harpoon.ui").nav_file(1)', opts) +vim.keymap.set('n', 'h2', 'lua require("harpoon.ui").nav_file(2)', opts) +vim.keymap.set('n', 'h3', 'lua require("harpoon.ui").nav_file(3)', opts) +vim.keymap.set('n', 'h4', 'lua require("harpoon.ui").nav_file(4)', opts) + +vim.keymap.set('n', 'sn', ':PackerSync', opts) + +-- DEBUG +vim.keymap.set('n', '', 'lua require("dap").continue()', opts) +vim.keymap.set('n', '', 'lua require("dap").step_over()', opts) +vim.keymap.set('n', '', 'lua require("dap").step_into()', opts) +vim.keymap.set('n', '', 'lua require("dap").step_out()', opts) +vim.keymap.set('n', 'b', 'lua require("dap").toggle_breakpoint()', opts) +vim.keymap.set('n', 'B', 'lua require("dap").set_breakpoint(vim.fn.input("Breakpoint condition: "))', opts) +vim.keymap.set('n', 'lp', 'lua require("dap").set_breakpoint(nil, nil, vim.fn.input("Log point message: "))', opts) +vim.keymap.set('n', 'dr', 'lua require("dap").repl.open()', opts) +vim.keymap.set('n', 'dl', 'lua require("dap").run_last()', opts) +vim.keymap.set('n', 'dc', 'lua require("dapui").close()', opts) + +--unbinds +-- vim.keymap.set('n', 'b', '', opts) diff --git a/init.lua b/init.lua index a7667ddc..3988c0a4 100644 --- a/init.lua +++ b/init.lua @@ -110,7 +110,7 @@ require('lazy').setup({ }, -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, + { 'folke/which-key.nvim', opts = {} }, { -- Adds git related signs to the gutter, as well as utilities for managing changes 'lewis6991/gitsigns.nvim', @@ -218,8 +218,8 @@ require('lazy').setup({ -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.debug', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping @@ -227,7 +227,7 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, {}) -- [[ Setting options ]] @@ -333,7 +333,8 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = vim.defer_fn(function() require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', + 'bash' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = false, @@ -472,12 +473,17 @@ require('mason-lspconfig').setup() -- If you want to override the default filetypes that your language server will attach to you can -- define the property 'filetypes' to the map in question. local servers = { - -- clangd = {}, + clangd = {}, -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + pyright = {}, + rust_analyzer = {}, + tsserver = {}, + eslint = {}, + html = { filetypes = { 'html', 'twig', 'hbs' } }, + yamlls = {}, + terraformls = {}, + jsonls = {}, + dockerls = {}, lua_ls = { Lua = { diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000..a0f13a32 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,34 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "a4de64570b9620875c8ea04175cd07ed8e32ac99" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" }, + "github-nvim-theme": { "branch": "main", "commit": "48f95f763e1a98e508260a20e448c3ff2d91213a" }, + "gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" }, + "harpoon": { "branch": "master", "commit": "c1aebbad9e3d13f20bedb8f2ce8b3a94e39e424a" }, + "indent-blankline.nvim": { "branch": "master", "commit": "29be0919b91fb59eca9e90690d76014233392bef" }, + "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "f0cd12f7a8a310c58cecebddb6b219ffad1cfd0f" }, + "mason.nvim": { "branch": "main", "commit": "eabf6d347fdb75be360d4c0ced1145670a171453" }, + "neodev.nvim": { "branch": "main", "commit": "80487e4f7bfa11c2ef2a1b461963db019aad6a73" }, + "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, + "nvim-dap": { "branch": "master", "commit": "4048f37bc8b1a36fe1f5fde0df7d84aef71380e4" }, + "nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" }, + "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, + "nvim-lspconfig": { "branch": "master", "commit": "b44737605807023d32e6310b87ba69f4dbf10e0e" }, + "nvim-treesitter": { "branch": "master", "commit": "bef2c24e23d0da62a8542b1f08b1ac87ec43e93f" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "e69a504baf2951d52e1f1fbb05145d43f236cbf1" }, + "onedark.nvim": { "branch": "master", "commit": "b9acd92ded2ba155867ca5af9d618e933d96e3b0" }, + "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, + "vim-be-good": { "branch": "master", "commit": "c290810728a4f75e334b07dc0f3a4cdea908d351" }, + "vim-fugitive": { "branch": "master", "commit": "46eaf8918b347906789df296143117774e827616" }, + "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, + "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } +} \ No newline at end of file diff --git a/lua/custom/plugins/harry.lua b/lua/custom/plugins/harry.lua new file mode 100644 index 00000000..3e6f10eb --- /dev/null +++ b/lua/custom/plugins/harry.lua @@ -0,0 +1,8 @@ +return { + "projekt0n/github-nvim-theme", + 'ThePrimeagen/vim-be-good', + { + 'ThePrimeagen/harpoon', + dependancies = { { 'nvim-lua/plenary.nvim' } } + }, +}