From d2e33f4c33a810d05398dca3418decb572134ae9 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Tue, 1 Nov 2022 14:52:38 +0000 Subject: [PATCH] Move plugin configs into dedicated files --- config_gitsigns.lua | 15 +++ lsp_config.lua => config_lsp.lua | 0 lualine_config.lua => config_lualine.lua | 2 +- config_nightfox.lua | 14 +++ config_nvim-tree.lua | 3 + config_plugins.lua | 12 +++ config_sniprun.lua | 7 ++ config_tabby.lua | 2 + config_telescope.lua | 14 +++ config_toggleterm.lua | 31 ++++++ init.lua | 118 +---------------------- init.vim | 1 - 12 files changed, 101 insertions(+), 118 deletions(-) create mode 100644 config_gitsigns.lua rename lsp_config.lua => config_lsp.lua (100%) rename lualine_config.lua => config_lualine.lua (78%) create mode 100644 config_nightfox.lua create mode 100644 config_nvim-tree.lua create mode 100644 config_plugins.lua create mode 100644 config_sniprun.lua create mode 100644 config_tabby.lua create mode 100644 config_telescope.lua create mode 100644 config_toggleterm.lua diff --git a/config_gitsigns.lua b/config_gitsigns.lua new file mode 100644 index 00000000..ee83adaa --- /dev/null +++ b/config_gitsigns.lua @@ -0,0 +1,15 @@ +require('gitsigns').setup{ + signcolumn = true, + numhl = true, + linehl = true, + current_line_blame = true, + on_attach = function(bufnr) + -- Setup keymaps + vim.api.nvim_buf_set_keymap(bufnr, 'n', '[g', 'Gitsigns prev_hunk', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', ']g', 'Gitsigns next_hunk', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hp', 'Gitsigns preview_hunk', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', 'Gitsigns select_hunk', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'bl', 'Gitsigns blame_line', {}) + vim.api.nvim_buf_set_keymap(bufnr, 'n', 'bt', 'Gitsigns toggle_current_line_blame', {}) + end, +} diff --git a/lsp_config.lua b/config_lsp.lua similarity index 100% rename from lsp_config.lua rename to config_lsp.lua diff --git a/lualine_config.lua b/config_lualine.lua similarity index 78% rename from lualine_config.lua rename to config_lualine.lua index 7722d179..330800c8 100644 --- a/lualine_config.lua +++ b/config_lualine.lua @@ -7,5 +7,5 @@ require('lualine').setup{ -- lualine_x = {'encoding', 'fileformat', 'filetype'}, lualine_x = {'aerial', 'filetype'} }, - extensions = {'aerial', 'fugitive', 'fzf', 'nerdtree'} + extensions = {'aerial', 'fugitive', 'fzf', 'nvim-tree', 'toggleterm'} } diff --git a/config_nightfox.lua b/config_nightfox.lua new file mode 100644 index 00000000..37b42c7b --- /dev/null +++ b/config_nightfox.lua @@ -0,0 +1,14 @@ +require('nightfox').setup{ + modules = { + aerial = true, + cmp = true, + diagnostic = true, + fidget = true, + gitgutter = true, + hop = true, + lsp_trouble = true, + nvimtree = true, + telescope = true, + treesitter = true, + }, +} diff --git a/config_nvim-tree.lua b/config_nvim-tree.lua new file mode 100644 index 00000000..220cd295 --- /dev/null +++ b/config_nvim-tree.lua @@ -0,0 +1,3 @@ +require('nvim-tree').setup{ + filters = { custom = { "^.git$" } } +} diff --git a/config_plugins.lua b/config_plugins.lua new file mode 100644 index 00000000..19ad8361 --- /dev/null +++ b/config_plugins.lua @@ -0,0 +1,12 @@ +require 'config_gitsigns' +require 'config_lualine' +require 'config_nightfox' +require 'config_nvim-tree' +require 'config_sniprun' +require 'config_tabby' +require 'config_telescope' +require 'config_toggleterm' + +require('trouble').setup() +require('fidget').setup() +require('hop').setup() diff --git a/config_sniprun.lua b/config_sniprun.lua new file mode 100644 index 00000000..1d74c063 --- /dev/null +++ b/config_sniprun.lua @@ -0,0 +1,7 @@ +require('sniprun').setup{ + selected_interpreters = { 'Python3_fifo' }, + repl_enable = {'Python3_fifo'}, + display = { + "NvimNotify" + }, +} diff --git a/config_tabby.lua b/config_tabby.lua new file mode 100644 index 00000000..df03f82e --- /dev/null +++ b/config_tabby.lua @@ -0,0 +1,2 @@ +vim.o.showtabline = 2 +require('tabby.tabline').use_preset('active_wins_at_tail', { nerdfont = false }) diff --git a/config_telescope.lua b/config_telescope.lua new file mode 100644 index 00000000..53c93f71 --- /dev/null +++ b/config_telescope.lua @@ -0,0 +1,14 @@ +require('telescope').load_extension('aerial') +require('telescope').load_extension('notify') + +local actions = require('telescope.actions') +local trouble = require('trouble.providers.telescope') + +require('telescope').setup{ + defaults = { + mappings = { + i = { [""] = trouble.open_with_trouble }, + n = { [""] = trouble.open_with_trouble }, + }, + }, +} diff --git a/config_toggleterm.lua b/config_toggleterm.lua new file mode 100644 index 00000000..03e46ec4 --- /dev/null +++ b/config_toggleterm.lua @@ -0,0 +1,31 @@ +require('toggleterm').setup{ + open_mapping = [[\t]], + size = 20, + hide_numbers = true, -- hide the number column in toggleterm buffers + persist_size = false, +} + +function _G.set_terminal_keymaps() + local opts = {buffer = 0} + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') + +local Terminal = require('toggleterm.terminal').Terminal +local lazygit = Terminal:new({ cmd = "lazygit", count = 99, direction = 'float' }) +local ranger = Terminal:new({ cmd = "ranger", count = 100, direction = 'float' }) + +function _lazygit_toggle() + lazygit:toggle() +end + +function _ranger_toggle() + ranger:toggle() +end + +vim.api.nvim_set_keymap("n", "g", "lua _lazygit_toggle()", {noremap = true, silent = true}) +vim.api.nvim_set_keymap("n", "r", "lua _ranger_toggle()", {noremap = true, silent = true}) diff --git a/init.lua b/init.lua index 6667c7ad..23535a33 100644 --- a/init.lua +++ b/init.lua @@ -1,117 +1,3 @@ -vim.o.showtabline = 2 -require('tabby.tabline').use_preset('active_wins_at_tail', { nerdfont = false }) -require('trouble').setup() -require('fidget').setup() -require('hop').setup() - --- gitsigns config -require('gitsigns').setup{ - signcolumn = true, - numhl = true, - linehl = true, - current_line_blame = true, - on_attach = function(bufnr) - -- Setup keymaps - vim.api.nvim_buf_set_keymap(bufnr, 'n', '[g', 'Gitsigns prev_hunk', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', ']g', 'Gitsigns next_hunk', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hp', 'Gitsigns preview_hunk', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', 'Gitsigns select_hunk', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'bl', 'Gitsigns blame_line', {}) - vim.api.nvim_buf_set_keymap(bufnr, 'n', 'bt', 'Gitsigns toggle_current_line_blame', {}) - end, -} - --- lualine config -require('lualine').setup{ - options = { - icons_enabled = true, - theme = 'auto', - }, - sections = { - -- lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_x = {'aerial', 'filetype'} - }, - extensions = {'aerial', 'fugitive', 'fzf', 'nvim-tree', 'toggleterm'} -} - --- nightfox setup -require('nightfox').setup{ - modules = { - aerial = true, - cmp = true, - diagnostic = true, - fidget = true, - gitgutter = true, - hop = true, - lsp_trouble = true, - nvimtree = true, - telescope = true, - treesitter = true, - }, -} - --- nvim-tree config -require('nvim-tree').setup{ - filters = { custom = { "^.git$" } } -} - --- toggleterm config -require('toggleterm').setup{ - open_mapping = [[\t]], - size = 20, - hide_numbers = true, -- hide the number column in toggleterm buffers - persist_size = false, -} - -function _G.set_terminal_keymaps() - local opts = {buffer = 0} - vim.keymap.set('t', '', [[wincmd h]], opts) - vim.keymap.set('t', '', [[wincmd j]], opts) - vim.keymap.set('t', '', [[wincmd k]], opts) - vim.keymap.set('t', '', [[wincmd l]], opts) -end - -vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') - -local Terminal = require('toggleterm.terminal').Terminal -local lazygit = Terminal:new({ cmd = "lazygit", count = 99, direction = 'float' }) -local ranger = Terminal:new({ cmd = "ranger", count = 100, direction = 'float' }) - -function _lazygit_toggle() - lazygit:toggle() -end - -function _ranger_toggle() - ranger:toggle() -end - -vim.api.nvim_set_keymap("n", "g", "lua _lazygit_toggle()", {noremap = true, silent = true}) -vim.api.nvim_set_keymap("n", "r", "lua _ranger_toggle()", {noremap = true, silent = true}) - --- load telescope integrations -require('telescope').load_extension('aerial') -require('telescope').load_extension('notify') - -local actions = require('telescope.actions') -local trouble = require('trouble.providers.telescope') - -require('telescope').setup{ - defaults = { - mappings = { - i = { [""] = trouble.open_with_trouble }, - n = { [""] = trouble.open_with_trouble }, - }, - }, -} - --- Set nvim-notify as default for notifications vim.notify = require("notify") - --- SnipRun config -require('sniprun').setup{ - selected_interpreters = { 'Python3_fifo' }, - repl_enable = {'Python3_fifo'}, - display = { - "NvimNotify" - }, -} +require 'config_lsp' +require 'config_plugins' diff --git a/init.vim b/init.vim index 2d356edd..56b7e6be 100644 --- a/init.vim +++ b/init.vim @@ -65,7 +65,6 @@ endif colorscheme nightfox luafile ~/.vim/init.lua -luafile ~/.vim/lsp_config.lua if executable('ag') let g:ackprg = 'ag --vimgrep'