Refactor: file per plugin in nvim

This commit is contained in:
Trevor Vallender 2024-03-04 14:36:33 +00:00
parent 15924b69d1
commit 221802f30e
24 changed files with 170 additions and 159 deletions

View File

@ -1,3 +1,4 @@
vim.g.mapleader = " "
require('options')
require('plugins') -- Install plugins with Lazy
require('completion') -- Completion

View File

@ -11,77 +11,4 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
-- Gruvbox theme
{ "ellisonleao/gruvbox.nvim", priority = 1000 , config = true },
-- Telescope: fuzzy finder
{
'nvim-telescope/telescope.nvim', tag = '0.1.4',
dependencies = { 'nvim-lua/plenary.nvim' }
},
-- File tree
"nvim-tree/nvim-tree.lua",
-- Treesitter
"nvim-treesitter/nvim-treesitter",
{
"Exafunction/codeium.vim",
config = function ()
-- Change '<C-g>' here to any keycode you like.
vim.keymap.set('i', '<C-g>', function () return vim.fn['codeium#Accept']() end, { expr = true })
vim.keymap.set('i', '<c-;>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true })
vim.keymap.set('i', '<c-,>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true })
vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true })
end
},
-- Completion framework
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lsp-document-symbol",
"hrsh7th/cmp-nvim-lsp-signature-help",
"ray-x/cmp-treesitter",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"andersevenrud/cmp-tmux",
"garyhurtz/cmp_kitty",
"kdheepak/cmp-latex-symbols",
"hrsh7th/cmp-emoji",
"Jezda1337/nvim-html-css",
-- LSP setup
"neovim/nvim-lspconfig",
-- Icons for Treesitter/nvim-tree
"nvim-tree/nvim-web-devicons",
-- LSP icons
"onsails/lspkind.nvim",
-- Git blame popup
"rhysd/git-messenger.vim",
-- Debugger
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
-- Vi motion within camelcase, underscore, etc
"chaoren/vim-wordmotion",
-- Git
"tpope/vim-fugitive",
-- Edit parens etc.
"tpope/vim-surround",
-- Rails utilities
"tpope/vim-rails",
-- Auto input 'end's
"rrethy/nvim-treesitter-endwise",
-- Blow shit up
"Eandrju/cellular-automaton.nvim",
-- Auto disable search highlight
"romainl/vim-cool",
-- Focus on current buffer
{
"folke/zen-mode.nvim",
opts = {
plugins = {
tmux = { enabled = true },
}
}
},
"mateuszwieloch/automkdir.nvim",
-- REPL
"https://gitlab.com/HiPhish/repl.nvim"
})
require("lazy").setup({ { import = "tsv.plugins" } })

View File

@ -1,4 +1,4 @@
vim.g.mapleader = " "
-- File browser
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- Text input
@ -6,89 +6,5 @@ vim.keymap.set('n', '<leader>pt', ":pu!=strftime('%R')<CR>");
vim.keymap.set('n', '<leader>pd', ":pu!=strftime('%F')<CR>");
vim.keymap.set('n', '<leader>pD', ":pu!=strftime('%c')<CR>");
-- Telescope
local builtin = require('telescope.builtin')
local telescope = require('telescope')
vim.keymap.set('n', '<leader>tf', "<cmd>Telescope find_files hidden=true<cr>", {}) -- Open files
vim.keymap.set('n', '<leader>ts', builtin.live_grep, {}) -- Grep files
vim.keymap.set('n', '<leader>tb', builtin.buffers, {}) -- Neovim buffers
vim.keymap.set('n', '<leader>tm', builtin.man_pages, {}) -- man pages
vim.keymap.set('n', '<leader>tp', builtin.registers, {}) -- Paste from registers
vim.keymap.set('n', '<leader>tt', builtin.resume, {}) -- Last open Telescope
vim.keymap.set('n', '<leader>to', builtin.oldfiles, {}) -- Recently opened files
-- Git functionality (tg prefix)
vim.keymap.set('n', '<leader>tgf', builtin.git_files, {})
vim.keymap.set('n', '<leader>tgc', builtin.git_commits, {})
vim.keymap.set('n', '<leader>tgh', builtin.git_bcommits, {}) -- Current buffer's commits
vim.keymap.set('n', '<leader>tgb', builtin.git_branches, {}) -- CR: checkout, C-t: track, C-r: rebase, C-a: create, C-s: switch, C-d: delete, C-y: merge
vim.keymap.set('n', '<leader>tgs', builtin.git_stash, {}) -- List stash, apply with CR
-- LSP functionality (tl prefix)
vim.keymap.set('n', '<leader>tla', function() vim.lsp.buf.code_action() end, bufopts)
vim.keymap.set('n', '<leader>tlr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>tli', builtin.lsp_incoming_calls, {})
vim.keymap.set('n', '<leader>tlo', builtin.lsp_outgoing_calls, {})
vim.keymap.set('n', '<leader>tld', builtin.lsp_definitions, {})
vim.keymap.set('n', '<leader>tlt', builtin.lsp_type_definitions, {})
vim.keymap.set('n', '<leader>tls', builtin.lsp_document_symbols, {})
vim.keymap.set('n', '<leader>tlm', builtin.lsp_implementations, {})
vim.keymap.set('n', '<leader>tlw', builtin.lsp_workspace_symbols, {})
vim.keymap.set('n', '<leader>tlD', builtin.diagnostics, {})
vim.keymap.set('n', '<leader>tlK', vim.lsp.buf.signature_help, {})
vim.keymap.set('n', '<leader>tlq', vim.diagnostic.setloclist, {})
vim.keymap.set('n', 'E', vim.diagnostic.open_float, {})
vim.keymap.set('n', 'H', function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>tlf", vim.lsp.buf.format) -- Format code
-- DAP
vim.keymap.set('n', '<leader>db', require('dap').toggle_breakpoint)
vim.keymap.set('n', '<leader>dc', require('dap').continue)
vim.keymap.set('n', '<leader>di', require('dap').step_into)
vim.keymap.set('n', '<leader>do', require('dap').step_over)
vim.keymap.set('n', '<leader>dr', require('dap').repl.open)
vim.keymap.set('n', '<leader>dx', require('dap').terminate)
-- Zen mode
vim.keymap.set('n', '<leader>zz', require('zen-mode').toggle)
-- AAAARGH
vim.keymap.set("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>")
vim.keymap.set("n", "<leader>cnw", "<cmd>CellularAutomaton game_of_life<CR>")
-- Codeium
vim.keymap.set("n", "<leader>cc", "<cmd>call codeium#Chat()<CR>")
-- Custom Telescope commands for Rails
vim.keymap.set('n', '<leader>trj', function()
builtin.find_files({ search_dirs = { "app/javascript", "app/assets/javascripts" } })
end, { desc = "Open Rails Javascripts" } )
vim.keymap.set('n', '<leader>trsj', function()
builtin.live_grep({ search_dirs = { "app/javascript", "app/assets/javascripts" } })
end, { desc = "Grep Rails Javascripts" } )
vim.keymap.set('n', '<leader>trm', function()
builtin.find_files({ search_dirs = { "app/models" } })
end, { desc = "Open Rails Models" } )
vim.keymap.set('n', '<leader>trsm', function()
builtin.live_grep({ search_dirs = { "app/models" } })
end, { desc = "Grep Rails Models" } )
vim.keymap.set('n', '<leader>trc', function()
builtin.find_files({ search_dirs = { "app/controllers" } })
end, { desc = "Open Rails Controllers" } )
vim.keymap.set('n', '<leader>trsc', function()
builtin.live_grep({ search_dirs = { "app/controllers" } })
end, { desc = "Grep Rails Controllers" } )
vim.keymap.set('n', '<leader>trv', function()
builtin.find_files({ search_dirs = { "app/views" } })
end, { desc = "Open Rails Views" } )
vim.keymap.set('n', '<leader>trsv', function()
builtin.live_grep({ search_dirs = { "app/views" } })
end, { desc = "Grep Rails Views" } )
-- Fugitive
vim.keymap.set('n', '<leader>gs', vim.cmd.Git);
vim.keymap.set('n', '<leader>ds', ':Gvdiffsplit!<CR>');
vim.keymap.set('n', '<leader>gl', ':diffget //2<CR>'); -- 'Get left' window
vim.keymap.set('n', '<leader>gr', ':diffget //3<CR>'); -- 'Get right' window
-- Git messenger
vim.keymap.set('n', '<leader>gm', ':GitMessenger<CR>');
-- Nvim-tree
vim.keymap.set("n", "<leader>nt", vim.cmd.NvimTreeToggle, {})
vim.keymap.set("n", "<leader>gp", "<cmd>lua require('goto-preview').goto_preview_definition()<CR>", {noremap=true})

View File

@ -0,0 +1,12 @@
return {
"hrsh7th/nvim-cmp",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lsp-document-symbol",
"hrsh7th/cmp-nvim-lsp-signature-help",
"ray-x/cmp-treesitter",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"andersevenrud/cmp-tmux",
"garyhurtz/cmp_kitty",
"kdheepak/cmp-latex-symbols",
}

View File

@ -0,0 +1,10 @@
return {
"Exafunction/codeium.vim",
config = function ()
vim.keymap.set('i', '<C-g>', function () return vim.fn['codeium#Accept']() end, { expr = true })
vim.keymap.set('i', '<c-;>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true })
vim.keymap.set('i', '<c-,>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true })
vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true })
vim.keymap.set("n", "<leader>cc", "<cmd>call codeium#Chat()<CR>")
end,
}

View File

@ -0,0 +1,6 @@
return {
"rhysd/git-messenger.vim",
config = function()
vim.keymap.set('n', '<leader>gm', ':GitMessenger<CR>');
end
}

View File

@ -0,0 +1,5 @@
return {
"ellisonleao/gruvbox.nvim",
priority = 1000 ,
config = true,
}

View File

@ -0,0 +1,11 @@
return {
"neovim/nvim-lspconfig",
config = function()
vim.keymap.set('n', '<leader>la', function() vim.lsp.buf.code_action() end, bufopts)
vim.keymap.set('n', '<leader>lK', vim.lsp.buf.signature_help, {})
vim.keymap.set('n', '<leader>lq', vim.diagnostic.setloclist, {})
vim.keymap.set('n', 'E', vim.diagnostic.open_float, {})
vim.keymap.set('n', 'H', function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format) -- Format code
end
}

View File

@ -0,0 +1,3 @@
return {
"onsails/lspkind.nvim",
}

View File

@ -0,0 +1,3 @@
return {
"rcarriga/nvim-dap-ui",
}

View File

@ -0,0 +1,11 @@
return {
"mfussenegger/nvim-dap",
config = function()
vim.keymap.set('n', '<leader>db', require('dap').toggle_breakpoint)
vim.keymap.set('n', '<leader>dc', require('dap').continue)
vim.keymap.set('n', '<leader>di', require('dap').step_into)
vim.keymap.set('n', '<leader>do', require('dap').step_over)
vim.keymap.set('n', '<leader>dr', require('dap').repl.open)
vim.keymap.set('n', '<leader>dx', require('dap').terminate)
end
}

View File

@ -0,0 +1,3 @@
return {
"Jezda1337/nvim-html-css",
}

View File

@ -0,0 +1,3 @@
return {
"nvim-tree/nvim-tree.lua",
}

View File

@ -0,0 +1,3 @@
return {
"rrethy/nvim-treesitter-endwise",
}

View File

@ -0,0 +1,3 @@
return {
"nvim-tree/nvim-web-devicons",
}

View File

@ -0,0 +1,3 @@
return {
"https://gitlab.com/HiPhish/repl.nvim",
}

View File

@ -0,0 +1,57 @@
return {
'nvim-telescope/telescope.nvim', tag = '0.1.4',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local builtin = require('telescope.builtin')
local telescope = require('telescope')
vim.keymap.set('n', '<leader>tf', "<cmd>Telescope find_files hidden=true<cr>", {}) -- Open files
vim.keymap.set('n', '<leader>ts', builtin.live_grep, {}) -- Grep files
vim.keymap.set('n', '<leader>tb', builtin.buffers, {}) -- Neovim buffers
vim.keymap.set('n', '<leader>tm', builtin.man_pages, {}) -- man pages
vim.keymap.set('n', '<leader>tp', builtin.registers, {}) -- Paste from registers
vim.keymap.set('n', '<leader>tt', builtin.resume, {}) -- Last open Telescope
vim.keymap.set('n', '<leader>to', builtin.oldfiles, {}) -- Recently opened files
-- Git functionality (tg prefix)
vim.keymap.set('n', '<leader>tgf', builtin.git_files, {})
vim.keymap.set('n', '<leader>tgc', builtin.git_commits, {})
vim.keymap.set('n', '<leader>tgh', builtin.git_bcommits, {}) -- Current buffer's commits
vim.keymap.set('n', '<leader>tgb', builtin.git_branches, {}) -- CR: checkout, C-t: track, C-r: rebase, C-a: create, C-s: switch, C-d: delete, C-y: merge
vim.keymap.set('n', '<leader>tgs', builtin.git_stash, {}) -- List stash, apply with CR
-- LSP functionality (tl prefix)
vim.keymap.set('n', '<leader>tlr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>tli', builtin.lsp_incoming_calls, {})
vim.keymap.set('n', '<leader>tlo', builtin.lsp_outgoing_calls, {})
vim.keymap.set('n', '<leader>tld', builtin.lsp_definitions, {})
vim.keymap.set('n', '<leader>tlt', builtin.lsp_type_definitions, {})
vim.keymap.set('n', '<leader>tls', builtin.lsp_document_symbols, {})
vim.keymap.set('n', '<leader>tlm', builtin.lsp_implementations, {})
vim.keymap.set('n', '<leader>tlw', builtin.lsp_workspace_symbols, {})
vim.keymap.set('n', '<leader>tlD', builtin.diagnostics, {})
-- Custom Rails shortcuts
vim.keymap.set('n', '<leader>trj', function()
builtin.find_files({ search_dirs = { "app/javascript", "app/assets/javascripts" } })
end, { desc = "Open Rails Javascripts" } )
vim.keymap.set('n', '<leader>trsj', function()
builtin.live_grep({ search_dirs = { "app/javascript", "app/assets/javascripts" } })
end, { desc = "Grep Rails Javascripts" } )
vim.keymap.set('n', '<leader>trm', function()
builtin.find_files({ search_dirs = { "app/models" } })
end, { desc = "Open Rails Models" } )
vim.keymap.set('n', '<leader>trsm', function()
builtin.live_grep({ search_dirs = { "app/models" } })
end, { desc = "Grep Rails Models" } )
vim.keymap.set('n', '<leader>trc', function()
builtin.find_files({ search_dirs = { "app/controllers" } })
end, { desc = "Open Rails Controllers" } )
vim.keymap.set('n', '<leader>trsc', function()
builtin.live_grep({ search_dirs = { "app/controllers" } })
end, { desc = "Grep Rails Controllers" } )
vim.keymap.set('n', '<leader>trv', function()
builtin.find_files({ search_dirs = { "app/views" } })
end, { desc = "Open Rails Views" } )
vim.keymap.set('n', '<leader>trsv', function()
builtin.live_grep({ search_dirs = { "app/views" } })
end, { desc = "Grep Rails Views" } )
end,
}

View File

@ -0,0 +1,4 @@
return {
"nvim-treesitter/nvim-treesitter",
}

View File

@ -0,0 +1,4 @@
-- Disables search highlights automatically
return {
"romainl/vim-cool",
}

View File

@ -0,0 +1,9 @@
return {
"tpope/vim-fugitive",
config = function()
vim.keymap.set('n', '<leader>gs', vim.cmd.Git);
vim.keymap.set('n', '<leader>ds', ':Gvdiffsplit!<CR>');
vim.keymap.set('n', '<leader>gl', ':diffget //2<CR>'); -- 'Get left' window
vim.keymap.set('n', '<leader>gr', ':diffget //3<CR>'); -- 'Get right' window
end
}

View File

@ -0,0 +1,3 @@
return {
"tpope/vim-rails",
}

View File

@ -0,0 +1,3 @@
return {
"tpope/vim-surround",
}

View File

@ -0,0 +1,3 @@
return {
"chaoren/vim-wordmotion",
}

View File

@ -0,0 +1,8 @@
return {
"folke/zen-mode.nvim",
opts = {
plugins = {
tmux = { enabled = true },
}
},
}