From 5887fc58e27d22d2d04d6576cae20aba3c951a27 Mon Sep 17 00:00:00 2001 From: Jimmy Bates Date: Sat, 20 Apr 2024 18:52:34 -0700 Subject: [PATCH] a bunch of stuff added . . . --- init.lua | 65 +++++++++++++++++------------- lua/custom/coloring/init.lua | 3 ++ lua/custom/init.lua | 3 ++ lua/custom/mappings/init.lua | 11 +++++ lua/custom/plugins/barbar.lua | 28 +++++++++++++ lua/custom/plugins/copilot.lua | 14 +++++++ lua/custom/plugins/init.lua | 5 --- lua/custom/plugins/scope.lua | 0 lua/kickstart/plugins/neo-tree.lua | 6 ++- lua/themes/themes.lua | 0 10 files changed, 101 insertions(+), 34 deletions(-) create mode 100644 lua/custom/coloring/init.lua create mode 100644 lua/custom/init.lua create mode 100644 lua/custom/mappings/init.lua create mode 100644 lua/custom/plugins/barbar.lua create mode 100644 lua/custom/plugins/copilot.lua delete mode 100644 lua/custom/plugins/init.lua create mode 100644 lua/custom/plugins/scope.lua create mode 100644 lua/themes/themes.lua diff --git a/init.lua b/init.lua index 3c70d736..fd75dd29 100644 --- a/init.lua +++ b/init.lua @@ -72,7 +72,7 @@ Kickstart Guide: NOTE: Look for lines like this - Throughout the file. These are for you, the reader, to help you understand what is happening. + Feel free to delete them once you know what you're doing, but they should serve as a guide for when you are first encountering a few different constructs in your Neovim config. @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -139,6 +139,9 @@ vim.opt.timeoutlen = 300 vim.opt.splitright = true vim.opt.splitbelow = true +-- Use terminal colours +vim.opt.termguicolors = true + -- Sets how neovim will display certain whitespace characters in the editor. -- See `:help 'list'` -- and `:help 'listchars'` @@ -224,6 +227,7 @@ vim.opt.rtp:prepend(lazypath) -- :Lazy update -- -- NOTE: Here is where you install your plugins. + require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically @@ -258,6 +262,8 @@ require('lazy').setup({ }, }, + { 'tiagovla/scope.nvim' }, + -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- -- This is often very useful to both group configuration, as well as handle @@ -284,10 +290,11 @@ require('lazy').setup({ ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, + ['f'] = { name = '[F]ind', _ = 'which_key_ignore' }, ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, + --['e'] = { name = '[E]xplore files', _ = 'which_key_ignore' }, } -- visual mode require('which-key').register({ @@ -366,45 +373,48 @@ require('lazy').setup({ }, } + -- Scope + require('scope').setup {} + -- Enable Telescope extensions if they are installed pcall(require('telescope').load_extension, 'fzf') pcall(require('telescope').load_extension, 'ui-select') -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) - vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) - vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) - vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) - vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) - vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) - vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) - vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 'fh', builtin.help_tags, { desc = '[F]ind [H]elp' }) + vim.keymap.set('n', 'fk', builtin.keymaps, { desc = '[F]ind [K]eymaps' }) + vim.keymap.set('n', 'ff', builtin.find_files, { desc = '[F]ind [F]iles' }) + vim.keymap.set('n', 'fs', builtin.builtin, { desc = '[F]ind [S]elect Telescope' }) + vim.keymap.set('n', 'fw', builtin.grep_string, { desc = '[F]ind current [W]ord' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = '[F]ind by [G]rep' }) + vim.keymap.set('n', 'fd', builtin.diagnostics, { desc = '[F]ind [D]iagnostics' }) + vim.keymap.set('n', 'fr', builtin.resume, { desc = '[F]ind [R]esume' }) + vim.keymap.set('n', 'f.', builtin.oldfiles, { desc = '[F]ind Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme - vim.keymap.set('n', '/', function() + vim.keymap.set('n', 's', function() -- You can pass additional configuration to Telescope to change the theme, layout, etc. builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) - end, { desc = '[/] Fuzzily search in current buffer' }) + end, { desc = '[S] Fuzzily search in current buffer' }) -- It's also possible to pass additional configuration options. -- See `:help telescope.builtin.live_grep()` for information about particular keys - vim.keymap.set('n', 's/', function() + vim.keymap.set('n', 'f/', function() builtin.live_grep { grep_open_files = true, prompt_title = 'Live Grep in Open Files', } - end, { desc = '[S]earch [/] in Open Files' }) + end, { desc = '[F]ind [/] in Open Files' }) -- Shortcut for searching your Neovim configuration files - vim.keymap.set('n', 'sn', function() + vim.keymap.set('n', 'fn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } - end, { desc = '[S]earch [N]eovim files' }) + end, { desc = '[F]ind [N]eovim files' }) end, }, @@ -469,7 +479,7 @@ require('lazy').setup({ -- Jump to the definition of the word under your cursor. -- This is where a variable was first declared, or where a function is defined, etc. -- To jump back, press . - map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + map('gd', require('telescope.builtin').lsp_definitions, '[g]oto [d]efinition') -- Find references for the word under your cursor. map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') @@ -619,7 +629,7 @@ require('lazy').setup({ lazy = false, keys = { { - 'f', + 'F', function() require('conform').format { async = true, lsp_fallback = true } end, @@ -714,7 +724,6 @@ require('lazy').setup({ -- Scroll the documentation window [b]ack / [f]orward [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. @@ -862,11 +871,13 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.debug', + require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.neo-tree', + require 'custom.plugins.barbar', + require 'custom.plugins.copilot', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -874,7 +885,6 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the @@ -897,5 +907,6 @@ require('lazy').setup({ }, }) +require 'custom' -- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +-- vim: ts=2 sts=2 sw=2 t diff --git a/lua/custom/coloring/init.lua b/lua/custom/coloring/init.lua new file mode 100644 index 00000000..c755b54f --- /dev/null +++ b/lua/custom/coloring/init.lua @@ -0,0 +1,3 @@ +vim.api.nvim_set_hl(0, 'LineNr', { fg = '#DDEEFF' }) +vim.api.nvim_set_hl(0, 'Comment', { fg = '#666666' }) +vim.api.nvim_set_hl(0, 'SpecialComment', { fg = '#666677' }) diff --git a/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 00000000..60f426f1 --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1,3 @@ +-- Mappings +require 'custom.mappings' +require 'custom.coloring' diff --git a/lua/custom/mappings/init.lua b/lua/custom/mappings/init.lua new file mode 100644 index 00000000..95186244 --- /dev/null +++ b/lua/custom/mappings/init.lua @@ -0,0 +1,11 @@ +-- Problems window +vim.keymap.set('n', 'Co', 'copen') +vim.keymap.set('n', 'Cp', 'cprev') +vim.keymap.set('n', 'Cn', 'cnext') + +-- Select all +vim.keymap.set('n', '', 'ggVG') + +-- Stop deselecting after indenting +vim.keymap.set('v', '<', '', '>gv') diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua new file mode 100644 index 00000000..24d76a45 --- /dev/null +++ b/lua/custom/plugins/barbar.lua @@ -0,0 +1,28 @@ +return { + { + 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', -- OPTIONAL: for git status + 'nvim-tree/nvim-web-devicons', -- OPTIONAL: for file icons + }, + init = function() + vim.g.barbar_auto_setup = false + + local map = vim.api.nvim_set_keymap + local opts = { noremap = true, silent = true } + + map('n', '', 'BufferPrevious', opts) + map('n', '', 'BufferPrevious', opts) + map('n', 'xx', 'BufferClose', vim.tbl_extend('force', opts, { desc = '[X] Close buffer' })) + map('n', 'xl', 'BufferCloseBuffersLeft', vim.tbl_extend('force', opts, { desc = '[L] Close all buffers left' })) + map('n', 'xr', 'BufferCloseBuffersRight', vim.tbl_extend('force', opts, { desc = '[R] Close all buffers right' })) + end, + opts = { + -- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default: + -- animation = true, + -- insert_at_start = true, + -- …etc. + }, + version = '^1.0.0', -- optional: only update when a new 1.x version is released + }, +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..5ab2812e --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,14 @@ +return { + 'github/copilot.vim', + lazy = false, + init = function() + local map = vim.api.nvim_set_keymap + + map('i', '', 'copilot#Accept("")', { expr = true, silent = true }) + end, + config = function() + vim.g.copilot_no_tab_map = true + vim.g.copilot_assume_mapped = true + vim.g.copilot_tab_fallback = '' + end, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua deleted file mode 100644 index be0eb9d8..00000000 --- a/lua/custom/plugins/init.lua +++ /dev/null @@ -1,5 +0,0 @@ --- You can add your own plugins here or in other files in this directory! --- I promise not to create any merge conflicts in this directory :) --- --- See the kickstart.nvim README for more information -return {} diff --git a/lua/custom/plugins/scope.lua b/lua/custom/plugins/scope.lua new file mode 100644 index 00000000..e69de29b diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index c793b885..4f3a736c 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -11,13 +11,15 @@ return { }, cmd = 'Neotree', keys = { - { '\\', ':Neotree reveal', { desc = 'NeoTree reveal' } }, + { '', ':Neotree toggle', { desc = 'NeoTree toggle' } }, + { 'e', ':Neotree reveal', mode = '', desc = '[E]xplore files' }, }, opts = { filesystem = { window = { mappings = { - ['\\'] = 'close_window', + [''] = 'toggle', + ['e'] = 'close_window', }, }, }, diff --git a/lua/themes/themes.lua b/lua/themes/themes.lua new file mode 100644 index 00000000..e69de29b