From 5edfba8462c00c42a093ab22987112f1e3c09772 Mon Sep 17 00:00:00 2001 From: Michael Beasley Date: Tue, 29 Oct 2024 14:49:48 -0500 Subject: [PATCH] pretty stable commit while things are pretty much working how I like --- init.lua | 317 ++++++++++++++++++----------- lua/custom/plugins/barbar.lua | 19 ++ lua/custom/plugins/init.lua | 5 - lua/custom/plugins/lazygit.lua | 20 ++ lua/custom/plugins/persistence.lua | 19 ++ lua/kickstart/plugins/lint.lua | 55 ----- lua/kickstart/plugins/neo-tree.lua | 4 +- 7 files changed, 254 insertions(+), 185 deletions(-) create mode 100644 lua/custom/plugins/barbar.lua delete mode 100644 lua/custom/plugins/init.lua create mode 100644 lua/custom/plugins/lazygit.lua create mode 100644 lua/custom/plugins/persistence.lua delete mode 100644 lua/kickstart/plugins/lint.lua diff --git a/init.lua b/init.lua index ea86b792..5f4454c8 100644 --- a/init.lua +++ b/init.lua @@ -1,89 +1,3 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. - - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - 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. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. - -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) ---]] - -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used) @@ -91,7 +5,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` @@ -118,6 +32,9 @@ vim.schedule(function() vim.opt.clipboard = 'unnamedplus' end) +-- Set syntax highlighting for .hujson to json +vim.cmd [[au BufNewFile,BufRead *.hujson setf json]] + -- Enable break indent vim.opt.breakindent = true @@ -162,8 +79,27 @@ vim.opt.scrolloff = 10 -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` + vim.keymap.set('n', '', 'nohlsearch') +-- Buffer keymaps +local map = vim.keymap.set +map('n', 'bn', 'enew', { desc = '[B]uffer [N]ew' }) +map('n', '', 'BufferPrevious', { desc = 'Cycle Previous Buffer' }) +map('n', '', 'BufferNext', { desc = 'Cycle Next Buffer' }) +map('n', 'bN', 'BufferOrderByName', { desc = '[B]uffer Order by [N]ame' }) +map('n', 'bc', 'BufferClose!', { desc = '[B]uffer [C]lose' }) +map('n', 'br', 'BufferRestore', { desc = '[B]uffer [R]estore' }) +map('n', 'tc', 'gcc', { desc = '[T]oggle [C]omment', remap = true }) +map('v', 'tc', 'gc', { desc = '[T]oggle [C]omment', remap = true }) +map('n', ';', ':', { desc = 'CMD enter command mode' }) + +-- Floaterm keymaps +map('n', 'tt', 'FloatermToggle', { desc = '[T]erminal [T]toggle' }) +map('n', 'tn', 'FloatermNew', { desc = '[T]erminal [New]' }) +map('n', 'tN', 'FloatermNext', { desc = 'Cycle Next Terminal' }) +vim.g.floaterm_title = 'Terminal ($1/$2)' + -- Diagnostic keymaps vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) @@ -204,6 +140,15 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Enable concealing characters on certain filetypes +-- For markdown this renders inline links, etc +vim.api.nvim_create_autocmd('FileType', { + pattern = { 'markdown' }, + callback = function() + vim.opt.conceallevel = 3 + end, +}) + -- [[ Install `lazy.nvim` plugin manager ]] -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' @@ -228,6 +173,49 @@ vim.opt.rtp:prepend(lazypath) -- -- NOTE: Here is where you install your plugins. require('lazy').setup({ + -- Automatically check for updates + checker = { + enabled = true, + notify = true, + }, + -- Enable caching + performance = { + cache = { + enabled = true, + }, + -- Disable some rtp plugins for performance + rtp = { + disabled_plugins = { + '2html_plugin', + 'tohtml', + 'getscript', + 'getscriptPlugin', + 'gzip', + 'logipat', + 'netrw', + 'netrwPlugin', + 'netrwSettings', + 'netrwFileHandlers', + 'matchit', + 'tar', + 'tarPlugin', + 'rrhelper', + 'spellfile_plugin', + 'vimball', + 'vimballPlugin', + 'zip', + 'zipPlugin', + 'tutor', + 'rplugin', + 'syntax', + 'synmenu', + 'optwin', + 'compiler', + 'bugreport', + 'ftplugin', + }, + }, + }, -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically @@ -243,18 +231,18 @@ require('lazy').setup({ -- require('gitsigns').setup({ ... }) -- -- See `:help gitsigns` to understand what the configuration keys do - { -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - }, - }, + -- { -- Adds git related signs to the gutter, as well as utilities for managing changes + -- 'lewis6991/gitsigns.nvim', + -- opts = { + -- signs = { + -- add = { text = '+' }, + -- change = { text = '~' }, + -- delete = { text = '_' }, + -- topdelete = { text = '‾' }, + -- changedelete = { text = '~' }, + -- }, + -- }, + -- }, -- NOTE: Plugins can also be configured to run Lua code when they are loaded. -- @@ -270,6 +258,7 @@ require('lazy').setup({ -- Then, because we use the `config` key, the configuration only runs -- after the plugin has been loaded: -- config = function() ... end + { 'voldikss/vim-floaterm' }, { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', @@ -317,9 +306,11 @@ require('lazy').setup({ { 'c', group = '[C]ode', mode = { 'n', 'x' } }, { 'd', group = '[D]ocument' }, { 'r', group = '[R]ename' }, + { 'g', group = '[G]it' }, { 's', group = '[S]earch' }, { 'w', group = '[W]orkspace' }, { 't', group = '[T]oggle' }, + { 'b', group = '[B]uffer' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, }, }, @@ -382,11 +373,12 @@ require('lazy').setup({ -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, + defaults = { + layout_config = { + prompt_position = 'top', + }, + sorting_strategy = 'ascending', + }, -- pickers = {} extensions = { ['ui-select'] = { @@ -401,6 +393,9 @@ require('lazy').setup({ -- See `:help telescope.builtin` local builtin = require 'telescope.builtin' + vim.keymap.set('n', 'gs', builtin.git_status, { desc = '[G]it [S]tatus' }) + vim.keymap.set('n', 'gc', builtin.git_commits, { desc = '[G]it [C]ommits' }) + vim.keymap.set('n', 'gb', builtin.git_branches, { desc = '[G]it [B]ranches' }) 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' }) @@ -606,8 +601,56 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, - -- pyright = {}, + gopls = {}, + jsonls = {}, + ansiblels = { + settings = { + ansible = { + validation = { + enabled = true, + lint = { + enabled = true, + }, + }, + }, + }, + }, + -- pyright { + bashls = {}, + terraformls = {}, + yamlls = { + settings = { + yaml = { + keyOrdering = false, + }, + }, + }, + pylsp = { + settings = { + pylsp = { + plugins = { + -- Formatters + autopep8 = { enabled = true }, + black = { enabled = false }, + pyls_isort = { enabled = true }, + yapf = { enabled = false }, + -- Linters + pylint = { enabled = false }, + pyflakes = { enabled = true }, + pycodestyle = { + ignore = { 'W391' }, + maxLineLength = 130, + }, + -- Complexity Checkers + mccabe = { enabled = true }, + -- Type Checkers + pylsp_mypy = { enabled = true }, + -- Auto-completers + jedi_completion = { fuzzy = true }, + }, + }, + }, + }, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -647,6 +690,11 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'python-lsp-server', + 'terraform-ls', + 'bash-language-server', + 'autopep8', + 'json-lsp', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -699,6 +747,7 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + python = { 'autopep8' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -728,12 +777,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -779,9 +828,9 @@ require('lazy').setup({ -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -829,13 +878,18 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', - priority = 1000, -- Make sure to load this before all the other start plugins. + 'projekt0n/github-nvim-theme', + name = 'github-theme', + lazy = false, + priority = 1000, + config = function() + require('github-theme').setup {} + end, init = function() -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'github_dark' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' @@ -888,7 +942,24 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'diff', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'vim', + 'vimdoc', + 'hcl', + 'python', + 'go', + 'yaml', + 'markdown', + 'markdown_inline', + 'dockerfile', + 'toml', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -920,16 +991,16 @@ require('lazy').setup({ -- 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.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + 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` -- This is the easiest way to modularize your config. -- -- 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' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua new file mode 100644 index 00000000..a484adea --- /dev/null +++ b/lua/custom/plugins/barbar.lua @@ -0,0 +1,19 @@ +return { + { + 'romgrk/barbar.nvim', + dependencies = { + 'lewis6991/gitsigns.nvim', + 'nvim-tree/nvim-web-devicons', + }, + init = function() + vim.g.barbar_auto_setup = false + end, + opts = { + animation = true, + insert_at_start = true, + icons = {}, + }, + version = '^1.0.0', + }, + require('gitsigns').setup {}, +} 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/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000..0794409b --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,20 @@ +return { + 'kdheepak/lazygit.nvim', + lazy = true, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { 'lg', 'LazyGit', desc = '[L]azy[G]it' }, + }, +} diff --git a/lua/custom/plugins/persistence.lua b/lua/custom/plugins/persistence.lua new file mode 100644 index 00000000..82ea737c --- /dev/null +++ b/lua/custom/plugins/persistence.lua @@ -0,0 +1,19 @@ +return { + -- Session management. This saves your session in the background, + -- keeping track of open buffers, window arrangement, and more. + -- You can restore sessions when returning through the dashboard. + { + 'folke/persistence.nvim', + event = 'BufReadPre', + opts = {}, + -- stylua: ignore + keys = { + { "sS", function() require("persistence").select() end,desc = "[S]earch Previous [S]essions" }, + { "sR", function() require("persistence").load({ last = true }) end, desc = "Restore Last [S]ession" }, + { "sD", function() require("persistence").stop() end, desc = "Don't Save Current [S]ession" }, + }, + }, + + -- library used by other plugins + { 'nvim-lua/plenary.nvim', lazy = true }, +} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua deleted file mode 100644 index ca9bc237..00000000 --- a/lua/kickstart/plugins/lint.lua +++ /dev/null @@ -1,55 +0,0 @@ -return { - - { -- Linting - 'mfussenegger/nvim-lint', - event = { 'BufReadPre', 'BufNewFile' }, - config = function() - local lint = require 'lint' - lint.linters_by_ft = { - markdown = { 'markdownlint' }, - } - - -- To allow other plugins to add linters to require('lint').linters_by_ft, - -- instead set linters_by_ft like this: - -- lint.linters_by_ft = lint.linters_by_ft or {} - -- lint.linters_by_ft['markdown'] = { 'markdownlint' } - -- - -- However, note that this will enable a set of default linters, - -- which will cause errors unless these tools are available: - -- { - -- clojure = { "clj-kondo" }, - -- dockerfile = { "hadolint" }, - -- inko = { "inko" }, - -- janet = { "janet" }, - -- json = { "jsonlint" }, - -- markdown = { "vale" }, - -- rst = { "vale" }, - -- ruby = { "ruby" }, - -- terraform = { "tflint" }, - -- text = { "vale" } - -- } - -- - -- You can disable the default linters by setting their filetypes to nil: - -- lint.linters_by_ft['clojure'] = nil - -- lint.linters_by_ft['dockerfile'] = nil - -- lint.linters_by_ft['inko'] = nil - -- lint.linters_by_ft['janet'] = nil - -- lint.linters_by_ft['json'] = nil - -- lint.linters_by_ft['markdown'] = nil - -- lint.linters_by_ft['rst'] = nil - -- lint.linters_by_ft['ruby'] = nil - -- lint.linters_by_ft['terraform'] = nil - -- lint.linters_by_ft['text'] = nil - - -- Create autocommand which carries out the actual linting - -- on the specified events. - local lint_augroup = vim.api.nvim_create_augroup('lint', { clear = true }) - vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWritePost', 'InsertLeave' }, { - group = lint_augroup, - callback = function() - lint.try_lint() - end, - }) - end, - }, -} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd442269..dd128bf2 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -11,13 +11,13 @@ return { }, cmd = 'Neotree', keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + { 'e', ':Neotree reveal', desc = '[N]eoTree reveal', silent = true }, }, opts = { filesystem = { window = { mappings = { - ['\\'] = 'close_window', + ['e'] = 'close_window', }, }, },