diff --git a/config/nvim/lua/config/catppuccin.lua b/config/nvim/lua/config/catppuccin.lua new file mode 100644 index 00000000..1bb7de6c --- /dev/null +++ b/config/nvim/lua/config/catppuccin.lua @@ -0,0 +1,24 @@ +return { + flavour = "macchiato", + transparent_background = true, + term_colors = true, + integrations = { + dashboard = true, + gitsigns = true, + indent_blankline = { + enabled = true, + colored_indent_levels = true, + }, + cmp = true, + native_lsp = { + enabled = true, + }, + notify = true, + nvimtree = true, + treesitter = true, + treesitter_context = true, + telescope = true, + lsp_trouble = true, + which_key = true, + }, +} diff --git a/config/nvim/lua/config/dashboard.lua b/config/nvim/lua/config/dashboard.lua new file mode 100644 index 00000000..69b05e2e --- /dev/null +++ b/config/nvim/lua/config/dashboard.lua @@ -0,0 +1,31 @@ +return { + theme = "hyper", + config = { + week_header = { + enable = true, + }, + shortcut = { + { desc = " Update", group = "@property", action = "Lazy update", key = "u" }, + { + icon = " ", + icon_hl = "@variable", + desc = "Files", + group = "Label", + action = "Telescope find_files", + key = "f", + }, + { + desc = " Apps", + group = "DiagnosticHint", + action = "Telescope app", + key = "a", + }, + { + desc = " dotfiles", + group = "Number", + action = "Telescope dotfiles", + key = "d", + }, + }, + }, +} diff --git a/config/nvim/lua/config/diffview.lua b/config/nvim/lua/config/diffview.lua new file mode 100644 index 00000000..0c4a90c0 --- /dev/null +++ b/config/nvim/lua/config/diffview.lua @@ -0,0 +1,6 @@ +return { + enhanced_diff_hl = true, + file_panel = { + listing_style = "list", + }, +} diff --git a/config/nvim/lua/config/feline.lua b/config/nvim/lua/config/feline.lua new file mode 100644 index 00000000..00f0b001 --- /dev/null +++ b/config/nvim/lua/config/feline.lua @@ -0,0 +1,2 @@ +local components = require("ui.feline_components").get() +return { components = components } diff --git a/config/nvim/lua/config/gitsigns.lua b/config/nvim/lua/config/gitsigns.lua new file mode 100644 index 00000000..d1a5b04d --- /dev/null +++ b/config/nvim/lua/config/gitsigns.lua @@ -0,0 +1,45 @@ +return { + signcolumn = true, + numhl = true, + linehl = false, + current_line_blame = true, + word_diff = false, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then return "]c" end + vim.schedule(function() gs.next_hunk() end) + return "" + end, { expr = true }) + + map("n", "[c", function() + if vim.wo.diff then return "[c" end + vim.schedule(function() gs.prev_hunk() end) + return "" + end, { expr = true }) + + -- Actions + map({ "n", "v" }, "hs", ":Gitsigns stage_hunk") + map({ "n", "v" }, "hr", ":Gitsigns reset_hunk") + map("n", "hS", gs.stage_buffer) + map("n", "hu", gs.undo_stage_hunk) + map("n", "hR", gs.reset_buffer) + map("n", "hp", gs.preview_hunk) + map("n", "hb", function() gs.blame_line { full = true } end) + map("n", "tb", gs.toggle_current_line_blame) + map("n", "hd", gs.diffthis) + map("n", "hD", function() gs.diffthis "~" end) + map("n", "td", gs.toggle_deleted) + + -- Text object + map({ "o", "x" }, "ih", ":Gitsigns select_hunk") + end, +} diff --git a/config/nvim/lua/config/indent_blankline.lua b/config/nvim/lua/config/indent_blankline.lua new file mode 100644 index 00000000..58b3e20c --- /dev/null +++ b/config/nvim/lua/config/indent_blankline.lua @@ -0,0 +1,12 @@ +return { + show_current_context = true, + show_current_context_start = false, + char_highlight_list = { + "IndentBlanklineIndent1", + "IndentBlanklineIndent2", + "IndentBlanklineIndent3", + "IndentBlanklineIndent4", + "IndentBlanklineIndent5", + "IndentBlanklineIndent6", + }, +} diff --git a/config/nvim/lua/config/neotree.lua b/config/nvim/lua/config/neotree.lua new file mode 100644 index 00000000..95132150 --- /dev/null +++ b/config/nvim/lua/config/neotree.lua @@ -0,0 +1,20 @@ +return { + close_if_last_window = true, + filesystem = { + filtered_items = { + hide_dotfiles = false, + }, + group_empty_dirs = true, + }, + buffers = { + follow_current_file = true, + group_empty_dirs = true, + }, + git_status = { + group_empty_dirs = true, + }, + source_selector = { + winbar = true, + statusline = false, + }, +} diff --git a/config/nvim/lua/config/notify.lua b/config/nvim/lua/config/notify.lua new file mode 100644 index 00000000..e847a85e --- /dev/null +++ b/config/nvim/lua/config/notify.lua @@ -0,0 +1,3 @@ +return { + background_colour = "#000000", +} diff --git a/config/nvim/lua/config/nvim_test.lua b/config/nvim/lua/config/nvim_test.lua new file mode 100644 index 00000000..3790c295 --- /dev/null +++ b/config/nvim/lua/config/nvim_test.lua @@ -0,0 +1,6 @@ +return { + termOpts = { + direction = "horizontal", + keep_one = true, + }, +} diff --git a/config/nvim/lua/config/telescope.lua b/config/nvim/lua/config/telescope.lua new file mode 100644 index 00000000..7e6413ac --- /dev/null +++ b/config/nvim/lua/config/telescope.lua @@ -0,0 +1,17 @@ +local trouble = require "trouble.providers.telescope" +return { + defaults = { + layout_strategy = "flex", + mappings = { + i = { [""] = trouble.open_with_trouble }, + n = { [""] = trouble.open_with_trouble }, + }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + }, + }, +} diff --git a/config/nvim/lua/config/treesitter.lua b/config/nvim/lua/config/treesitter.lua new file mode 100644 index 00000000..be807f9d --- /dev/null +++ b/config/nvim/lua/config/treesitter.lua @@ -0,0 +1,7 @@ +return { + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + disable = { "fortran" }, + }, +} diff --git a/config/nvim/lua/config/trouble.lua b/config/nvim/lua/config/trouble.lua new file mode 100644 index 00000000..9d8a2091 --- /dev/null +++ b/config/nvim/lua/config/trouble.lua @@ -0,0 +1,7 @@ +return { + mode = "workspace_diagnostics", + auto_open = false, + auto_close = false, + auto_preview = true, + auto_jump = { "lsp_definitions", "lsp_references", "lsp_implementations" }, +} diff --git a/config/nvim/lua/lsp/init.lua b/config/nvim/lua/lsp/config.lua similarity index 55% rename from config/nvim/lua/lsp/init.lua rename to config/nvim/lua/lsp/config.lua index b22b778f..f71fc178 100644 --- a/config/nvim/lua/lsp/init.lua +++ b/config/nvim/lua/lsp/config.lua @@ -1,3 +1,5 @@ +local M = {} + -- Mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions local opts = { noremap = true, silent = true } @@ -13,39 +15,33 @@ for type, icon in pairs(signs) do end require("neodev").setup() - -local on_attach = require "lsp.attach" -local lsp_flags = require "lsp.flags" local lspconfig = require "lspconfig" -local capabilities = require("cmp_nvim_lsp").default_capabilities() + +M.on_attach = require "lsp.attach" +M.lsp_flags = require "lsp.flags" +M.capabilities = require("cmp_nvim_lsp").default_capabilities() lspconfig.pyright.setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, } lspconfig.fortls.setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, } lspconfig.lua_ls.setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, } lspconfig.texlab.setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, -} - -require("null-ls").setup { - sources = require "lsp.null_ls_sources", - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, } +return M diff --git a/config/nvim/lua/plugins/catppuccin.lua b/config/nvim/lua/plugins/catppuccin.lua index 2e5be25d..03e74a47 100644 --- a/config/nvim/lua/plugins/catppuccin.lua +++ b/config/nvim/lua/plugins/catppuccin.lua @@ -3,36 +3,12 @@ return { name = "catppuccin", lazy = false, priority = 1000, - config = function() + init = function() vim.opt.termguicolors = true require "ui.fillchars" - require("catppuccin").setup { - flavour = "macchiato", - -- transparent_background = true, - term_colors = true, - dim_inactive = { - enabled = true, - }, - integrations = { - dashboard = true, - gitsigns = true, - indent_blankline = { - enabled = true, - colored_indent_levels = true, - }, - cmp = true, - native_lsp = { - enabled = true, - }, - notify = true, - nvimtree = true, - treesitter = true, - treesitter_context = true, - telescope = true, - lsp_trouble = true, - which_key = true, - }, - } + end, + config = function() + require("catppuccin").setup(require "config.catppuccin") vim.cmd.colorscheme "catppuccin" end, } diff --git a/config/nvim/lua/plugins/dashboard.lua b/config/nvim/lua/plugins/dashboard.lua index 00d2c3b7..ea2b53d9 100644 --- a/config/nvim/lua/plugins/dashboard.lua +++ b/config/nvim/lua/plugins/dashboard.lua @@ -1,38 +1,6 @@ return { "glepnir/dashboard-nvim", event = "VimEnter", - config = function() - require("dashboard").setup { - theme = "hyper", - config = { - week_header = { - enable = true, - }, - shortcut = { - { desc = " Update", group = "@property", action = "Lazy update", key = "u" }, - { - icon = " ", - icon_hl = "@variable", - desc = "Files", - group = "Label", - action = "Telescope find_files", - key = "f", - }, - { - desc = " Apps", - group = "DiagnosticHint", - action = "Telescope app", - key = "a", - }, - { - desc = " dotfiles", - group = "Number", - action = "Telescope dotfiles", - key = "d", - }, - }, - }, - } - end, dependencies = { { "nvim-tree/nvim-web-devicons" } }, + config = function() require("dashboard").setup(require "config.dashboard") end, } diff --git a/config/nvim/lua/plugins/diffview.lua b/config/nvim/lua/plugins/diffview.lua index 23b7839c..97966432 100644 --- a/config/nvim/lua/plugins/diffview.lua +++ b/config/nvim/lua/plugins/diffview.lua @@ -5,12 +5,5 @@ return { "DiffviewOpen", "DiffviewFileHistory", }, - config = function() - require("diffview").setup { - enhanced_diff_hl = true, - file_panel = { - listing_style = "list", - }, - } - end, + config = function() require("diffview").setup(require "config.diffview") end, } diff --git a/config/nvim/lua/plugins/feline.lua b/config/nvim/lua/plugins/feline.lua index 98f2ca4a..d29b9e3b 100644 --- a/config/nvim/lua/plugins/feline.lua +++ b/config/nvim/lua/plugins/feline.lua @@ -1,8 +1,5 @@ return { "feline-nvim/feline.nvim", dependencies = { require "plugins.catppuccin" }, - config = function() - local components = require("ui.feline_components").get() - require("feline").setup { components = components } - end, + config = function() require("feline").setup(require "config.feline") end, } diff --git a/config/nvim/lua/plugins/gitsigns.lua b/config/nvim/lua/plugins/gitsigns.lua index 5cfd63b1..9230535a 100644 --- a/config/nvim/lua/plugins/gitsigns.lua +++ b/config/nvim/lua/plugins/gitsigns.lua @@ -1,51 +1,5 @@ return { "lewis6991/gitsigns.nvim", event = { "BufReadPre", "BufNewFile" }, - config = function() - require("gitsigns").setup { - signcolumn = true, - numhl = true, - linehl = false, - current_line_blame = true, - word_diff = false, - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map("n", "]c", function() - if vim.wo.diff then return "]c" end - vim.schedule(function() gs.next_hunk() end) - return "" - end, { expr = true }) - - map("n", "[c", function() - if vim.wo.diff then return "[c" end - vim.schedule(function() gs.prev_hunk() end) - return "" - end, { expr = true }) - - -- Actions - map({ "n", "v" }, "hs", ":Gitsigns stage_hunk") - map({ "n", "v" }, "hr", ":Gitsigns reset_hunk") - map("n", "hS", gs.stage_buffer) - map("n", "hu", gs.undo_stage_hunk) - map("n", "hR", gs.reset_buffer) - map("n", "hp", gs.preview_hunk) - map("n", "hb", function() gs.blame_line { full = true } end) - map("n", "tb", gs.toggle_current_line_blame) - map("n", "hd", gs.diffthis) - map("n", "hD", function() gs.diffthis "~" end) - map("n", "td", gs.toggle_deleted) - - -- Text object - map({ "o", "x" }, "ih", ":Gitsigns select_hunk") - end, - } - end, + config = function() require("gitsigns").setup(require "config.gitsigns") end, } diff --git a/config/nvim/lua/plugins/indent_blankline.lua b/config/nvim/lua/plugins/indent_blankline.lua index 58208526..b0ee0a93 100644 --- a/config/nvim/lua/plugins/indent_blankline.lua +++ b/config/nvim/lua/plugins/indent_blankline.lua @@ -1,18 +1,5 @@ return { "lukas-reineke/indent-blankline.nvim", event = { "BufReadPre", "BufNewFile" }, - config = function() - require("indent_blankline").setup { - show_current_context = true, - show_current_context_start = false, - char_highlight_list = { - "IndentBlanklineIndent1", - "IndentBlanklineIndent2", - "IndentBlanklineIndent3", - "IndentBlanklineIndent4", - "IndentBlanklineIndent5", - "IndentBlanklineIndent6", - }, - } - end, + config = function() require("indent_blankline").setup(require "config.indent_blankline") end, } diff --git a/config/nvim/lua/plugins/lspconfig.lua b/config/nvim/lua/plugins/lspconfig.lua index 0aee6514..abc96292 100644 --- a/config/nvim/lua/plugins/lspconfig.lua +++ b/config/nvim/lua/plugins/lspconfig.lua @@ -19,7 +19,13 @@ return { { "folke/neodev.nvim" }, }, config = function() - require "lsp.init" + local config = require "lsp.config" + require("null-ls").setup { + sources = require "lsp.null_ls_sources", + on_attach = config.on_attach, + flags = config.lsp_flags, + capabilities = config.capabilities, + } require "lsp.cmp" end, } diff --git a/config/nvim/lua/plugins/neotree.lua b/config/nvim/lua/plugins/neotree.lua index c52500e1..7686f282 100644 --- a/config/nvim/lua/plugins/neotree.lua +++ b/config/nvim/lua/plugins/neotree.lua @@ -9,25 +9,6 @@ return { cmd = "Neotree", config = function() vim.cmd [[ let g:neo_tree_remove_legacy_commands = 1 ]] - require("neo-tree").setup { - close_if_last_window = true, - filesystem = { - filtered_items = { - hide_dotfiles = false, - }, - group_empty_dirs = true, - }, - buffers = { - follow_current_file = true, - group_empty_dirs = true, - }, - git_status = { - group_empty_dirs = true, - }, - source_selector = { - winbar = true, - statusline = false, - }, - } + require("neo-tree").setup(require "config.neotree") end, } diff --git a/config/nvim/lua/plugins/notify.lua b/config/nvim/lua/plugins/notify.lua index dd286cfa..5d63ecd9 100644 --- a/config/nvim/lua/plugins/notify.lua +++ b/config/nvim/lua/plugins/notify.lua @@ -1,9 +1,7 @@ return { "rcarriga/nvim-notify", config = function() - require("notify").setup { - background_colour = "#000000", - } + require("notify").setup(require "config.notify") vim.notify = require "notify" end, } diff --git a/config/nvim/lua/plugins/nvim-test.lua b/config/nvim/lua/plugins/nvim_test.lua similarity index 50% rename from config/nvim/lua/plugins/nvim-test.lua rename to config/nvim/lua/plugins/nvim_test.lua index dd828d2e..e67d3343 100644 --- a/config/nvim/lua/plugins/nvim-test.lua +++ b/config/nvim/lua/plugins/nvim_test.lua @@ -9,12 +9,5 @@ return { "TestVisit", "TestInfo", }, - config = function() - require("nvim-test").setup { - termOpts = { - direction = "horizontal", - keep_one = true, - }, - } - end, + config = function() require("nvim-test").setup(require "config.nvim_test") end, } diff --git a/config/nvim/lua/plugins/telescope.lua b/config/nvim/lua/plugins/telescope.lua index 9c5696a6..6a1eea9f 100644 --- a/config/nvim/lua/plugins/telescope.lua +++ b/config/nvim/lua/plugins/telescope.lua @@ -12,25 +12,7 @@ return { cmd = "Telescope", config = function() require "telescope.actions" - local trouble = require "trouble.providers.telescope" - - require("telescope").setup { - defaults = { - layout_strategy = "cursor", - mappings = { - i = { [""] = trouble.open_with_trouble }, - n = { [""] = trouble.open_with_trouble }, - }, - }, - extensions = { - fzf = { - fuzzy = true, -- false will only do exact matching - override_generic_sorter = true, -- override the generic sorter - override_file_sorter = true, -- override the file sorter - }, - }, - } - + require("telescope").setup(require "config.telescope") require("telescope").load_extension "fzf" require("telescope").load_extension "notify" end, diff --git a/config/nvim/lua/plugins/treesitter.lua b/config/nvim/lua/plugins/treesitter.lua index 9afd6c65..8918d2a9 100644 --- a/config/nvim/lua/plugins/treesitter.lua +++ b/config/nvim/lua/plugins/treesitter.lua @@ -1,13 +1,5 @@ return { "nvim-treesitter/nvim-treesitter", event = { "BufReadPre", "BufNewFile" }, - config = function() - require("nvim-treesitter.configs").setup { - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - disable = { "fortran" }, - }, - } - end, + config = function() require("nvim-treesitter.configs").setup(require "config.treesitter") end, } diff --git a/config/nvim/lua/plugins/trouble.lua b/config/nvim/lua/plugins/trouble.lua index aa63e42a..1db52413 100644 --- a/config/nvim/lua/plugins/trouble.lua +++ b/config/nvim/lua/plugins/trouble.lua @@ -2,13 +2,5 @@ return { "folke/trouble.nvim", dependencies = "nvim-tree/nvim-web-devicons", cmd = "TroubleToggle", - config = function() - require("trouble").setup { - mode = "workspace_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - auto_open = false, -- automatically open the list when you have diagnostics - auto_close = false, -- automatically close the list when you have no diagnostics - auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window - auto_jump = { "lsp_definitions", "lsp_references", "lsp_implementations" }, -- for the given modes, automatically jump if there is only a single result - } - end, + config = function() require("trouble").setup(require "config.trouble") end, }