From fffc2e3d46ac883d54581492adac1427783e8279 Mon Sep 17 00:00:00 2001 From: mjhika <1zzt6ovh@mojica.anonaddy.com> Date: Thu, 7 Sep 2023 03:42:34 -0400 Subject: [PATCH] lots of refactoring and a new cmp source for clj --- init.lua | 193 ++++++------------------------ lua/custom/plugins/autocomp.lua | 18 +++ lua/custom/plugins/blankline.lua | 10 ++ lua/custom/plugins/comment.lua | 5 + lua/custom/plugins/gitsigns.lua | 20 ++++ lua/custom/plugins/line.lua | 13 ++ lua/custom/plugins/lsp.lua | 16 +++ lua/custom/plugins/telescope.lua | 20 ++++ lua/custom/plugins/theme.lua | 8 ++ lua/custom/plugins/tpopeStuff.lua | 10 ++ lua/custom/plugins/treesit.lua | 8 ++ lua/custom/plugins/whichkey.lua | 2 + 12 files changed, 164 insertions(+), 159 deletions(-) create mode 100644 lua/custom/plugins/autocomp.lua create mode 100644 lua/custom/plugins/blankline.lua create mode 100644 lua/custom/plugins/comment.lua create mode 100644 lua/custom/plugins/gitsigns.lua create mode 100644 lua/custom/plugins/line.lua create mode 100644 lua/custom/plugins/lsp.lua create mode 100644 lua/custom/plugins/telescope.lua create mode 100644 lua/custom/plugins/theme.lua create mode 100644 lua/custom/plugins/tpopeStuff.lua create mode 100644 lua/custom/plugins/treesit.lua create mode 100644 lua/custom/plugins/whichkey.lua diff --git a/init.lua b/init.lua index 35504ca3..18517958 100644 --- a/init.lua +++ b/init.lua @@ -25,148 +25,13 @@ vim.opt.rtp:prepend(lazypath) -- they can be configured with the `config` key or after they are setup since -- now they are in the runtime require('lazy').setup({ - -- NOTE: First, some plugins that don't require any configuration - - -- surround support - 'tpope/vim-surround', - - -- Git related plugins - 'tpope/vim-fugitive', - 'tpope/vim-rhubarb', - - -- Detect tabstop and shiftwidth automatically - 'tpope/vim-sleuth', - -- NOTE: This is where your plugins related to LSP can be installed. -- The configuration is done below. Search for lspconfig to find it below. - { - -- LSP Configuration & Plugins - 'neovim/nvim-lspconfig', - dependencies = { - -- Automatically install LSPs to stdpath for neovim - { 'williamboman/mason.nvim', config = true }, - 'williamboman/mason-lspconfig.nvim', - - -- Useful status updates for LSP - -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, - - -- Additional lua configuration, makes nvim stuff amazing! - 'folke/neodev.nvim', - }, - }, - - { - -- Autocompletion - 'hrsh7th/nvim-cmp', - dependencies = { - -- Snippet Engine & its associated nvim-cmp source - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', - - -- Adds LSP completion capabilities - 'hrsh7th/cmp-nvim-lsp', - - -- Adds a number of user-friendly snippets - 'rafamadriz/friendly-snippets', - }, - }, - - -- Useful plugin to show you pending keybinds. - { 'folke/which-key.nvim', opts = {} }, - { - -- Adds git related signs to the gutter, as well as utilities for managing changes - 'lewis6991/gitsigns.nvim', - opts = { - -- See `:help gitsigns.txt` - signs = { - add = { text = '+' }, - change = { text = '~' }, - delete = { text = '_' }, - topdelete = { text = '‾' }, - changedelete = { text = '~' }, - }, - on_attach = function(bufnr) - vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, - { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) - vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) - vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) - end, - }, - }, - - { - -- Theme inspired by Atom - 'sainnhe/everforest', - priority = 1000, - config = function() - vim.cmd.colorscheme 'everforest' - end, - }, - - { - -- Set lualine as statusline - 'nvim-lualine/lualine.nvim', - -- See `:help lualine.txt` - opts = { - options = { - icons_enabled = true, - theme = 'everforest', - component_separators = '|', - section_separators = '', - }, - }, - }, - - { - -- Add indentation guides even on blank lines - 'lukas-reineke/indent-blankline.nvim', - -- Enable `lukas-reineke/indent-blankline.nvim` - -- See `:help indent_blankline.txt` - opts = { - char = '┊', - show_trailing_blankline_indent = false, - }, - }, - - -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, - - -- Fuzzy Finder (files, lsp, etc) - { - 'nvim-telescope/telescope.nvim', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - -- Fuzzy Finder Algorithm which requires local dependencies to be built. - -- Only load if `make` is available. Make sure you have the system - -- requirements installed. - { - 'nvim-telescope/telescope-fzf-native.nvim', - -- NOTE: If you are having trouble with this installation, - -- refer to the README for telescope-fzf-native for more instructions. - build = 'make', - cond = function() - return vim.fn.executable 'make' == 1 - end, - }, - }, - }, - - { - -- Highlight, edit, and navigate code - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-treesitter/nvim-treesitter-textobjects', - }, - build = ':TSUpdate', - }, - -- 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.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 @@ -184,6 +49,9 @@ require('lazy').setup({ -- Set highlight on search vim.o.hlsearch = true +-- Set Colorcolumn because I like to immpose max lengths for my code +vim.o.colorcolumn = "80,120" + -- Make line numbers default vim.o.number = true vim.o.relativenumber = true @@ -255,7 +123,10 @@ vim.api.nvim_create_autocmd('TextYankPost', { -- [[ Configure Telescope ]] -- See `:help telescope` and `:help telescope.setup()` -require('telescope').setup { +local telscope = require('telescope') +local telscopeb = require('telescope.builtin') + +telscope.setup { defaults = { mappings = { i = { @@ -265,33 +136,36 @@ require('telescope').setup { }, }, } - -- Enable telescope fzf native, if installed -pcall(require('telescope').load_extension, 'fzf') +pcall(telscope.load_extension, 'fzf') -- See `:help telescope.builtin` -vim.keymap.set('n', '?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) -vim.keymap.set('n', '', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '?', telscopeb.oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '', telscopeb.buffers, { desc = '[ ] Find existing buffers' }) vim.keymap.set('n', '/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. - require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + telscopeb.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { winblend = 10, previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) -vim.keymap.set('n', 'gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) -vim.keymap.set('n', 'sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) -vim.keymap.set('n', 'sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) -vim.keymap.set('n', 'sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) -vim.keymap.set('n', 'sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) -vim.keymap.set('n', 'sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', 'fi', telscopeb.git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', 'ff', telscopeb.find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', 'fh', telscopeb.help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', 'fw', telscopeb.grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', 'fg', telscopeb.live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', 'fd', telscopeb.diagnostics, { desc = '[S]earch [D]iagnostics' }) -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` require('nvim-treesitter.configs').setup { -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'go', 'gomod', 'gosum', 'gowork', 'lua', 'vimdoc', 'vim', 'clojure', 'commonlisp', 'ocaml' }, + ensure_installed = { + 'c', 'go', 'gomod', + 'gosum', 'gowork', 'lua', + 'vimdoc', 'vim', 'clojure', + 'commonlisp', 'ocaml' }, -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) auto_install = true, @@ -356,8 +230,8 @@ require('nvim-treesitter.configs').setup { -- Diagnostic keymaps vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) +vim.keymap.set('n', 'le', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'lq', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. @@ -376,15 +250,15 @@ local on_attach = function(_, bufnr) vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) end - nmap('lrn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('lca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap('lr', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('lc', vim.lsp.buf.code_action, '[C]ode [A]ction') nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') - nmap('lD', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('lds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('lws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap('lt', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('ld', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('lw', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') -- See `:help K` for why this keymap nmap('K', vim.lsp.buf.hover, 'Hover Documentation') @@ -392,9 +266,9 @@ local on_attach = function(_, bufnr) -- Lesser used LSP functionality nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('lwa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('lwr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('lwl', function() + nmap('la', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('lR', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('ll', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, '[W]orkspace [L]ist Folders') @@ -499,6 +373,7 @@ cmp.setup { sources = { { name = 'nvim_lsp' }, { name = 'luasnip' }, + { name = 'conjure' }, }, } diff --git a/lua/custom/plugins/autocomp.lua b/lua/custom/plugins/autocomp.lua new file mode 100644 index 00000000..dd92ea58 --- /dev/null +++ b/lua/custom/plugins/autocomp.lua @@ -0,0 +1,18 @@ +return { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + + -- Adds Conjure cmp + 'PaterJason/cmp-conjure', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, +} diff --git a/lua/custom/plugins/blankline.lua b/lua/custom/plugins/blankline.lua new file mode 100644 index 00000000..56346a28 --- /dev/null +++ b/lua/custom/plugins/blankline.lua @@ -0,0 +1,10 @@ +return { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + opts = { + char = '┊', + show_trailing_blankline_indent = false, + }, +} diff --git a/lua/custom/plugins/comment.lua b/lua/custom/plugins/comment.lua new file mode 100644 index 00000000..dc277107 --- /dev/null +++ b/lua/custom/plugins/comment.lua @@ -0,0 +1,5 @@ +-- "gc" to comment visual regions/lines +return { + 'numToStr/Comment.nvim', + opts = {} +} diff --git a/lua/custom/plugins/gitsigns.lua b/lua/custom/plugins/gitsigns.lua new file mode 100644 index 00000000..3a7cc565 --- /dev/null +++ b/lua/custom/plugins/gitsigns.lua @@ -0,0 +1,20 @@ +return { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + vim.keymap.set('n', 'gp', require('gitsigns').prev_hunk, + { buffer = bufnr, desc = '[G]o to [P]revious Hunk' }) + vim.keymap.set('n', 'gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' }) + vim.keymap.set('n', 'ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' }) + end, + }, +} diff --git a/lua/custom/plugins/line.lua b/lua/custom/plugins/line.lua new file mode 100644 index 00000000..9b89b1d6 --- /dev/null +++ b/lua/custom/plugins/line.lua @@ -0,0 +1,13 @@ +return { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = true, + theme = 'everforest', + component_separators = '|', + section_separators = '', + }, + }, +} diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua new file mode 100644 index 00000000..6aa34102 --- /dev/null +++ b/lua/custom/plugins/lsp.lua @@ -0,0 +1,16 @@ +return { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 00000000..98ebdeab --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,20 @@ +-- Fuzzy Finder (files, lsp, etc) +return { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, +} diff --git a/lua/custom/plugins/theme.lua b/lua/custom/plugins/theme.lua new file mode 100644 index 00000000..48a91131 --- /dev/null +++ b/lua/custom/plugins/theme.lua @@ -0,0 +1,8 @@ +return { + -- Theme inspired by Atom + 'sainnhe/everforest', + priority = 1000, + config = function() + vim.cmd.colorscheme 'everforest' + end, +} diff --git a/lua/custom/plugins/tpopeStuff.lua b/lua/custom/plugins/tpopeStuff.lua new file mode 100644 index 00000000..686de6e9 --- /dev/null +++ b/lua/custom/plugins/tpopeStuff.lua @@ -0,0 +1,10 @@ +return { + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + + -- surround support + 'tpope/vim-surround', + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', +} diff --git a/lua/custom/plugins/treesit.lua b/lua/custom/plugins/treesit.lua new file mode 100644 index 00000000..48acfa5b --- /dev/null +++ b/lua/custom/plugins/treesit.lua @@ -0,0 +1,8 @@ +return { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ':TSUpdate', +} diff --git a/lua/custom/plugins/whichkey.lua b/lua/custom/plugins/whichkey.lua new file mode 100644 index 00000000..d3630cc0 --- /dev/null +++ b/lua/custom/plugins/whichkey.lua @@ -0,0 +1,2 @@ +-- Useful plugin to show you pending keybinds. +return { 'folke/which-key.nvim', opts = {} }