From afdd9da978940c69423f0b554b9c0ac694a45a87 Mon Sep 17 00:00:00 2001 From: Alexander Goussas Date: Sun, 15 Jun 2025 00:14:08 -0500 Subject: [PATCH] nvim: organize plugins --- nvim/.config/nvim/init.lua | 233 +----------------- nvim/.config/nvim/lua/plugins/colorscheme.lua | 8 + nvim/.config/nvim/lua/plugins/copilot.lua | 3 + nvim/.config/nvim/lua/plugins/core.lua | 34 +++ nvim/.config/nvim/lua/plugins/filetree.lua | 20 ++ nvim/.config/nvim/lua/plugins/git.lua | 11 + nvim/.config/nvim/lua/plugins/haskell.lua | 11 + nvim/.config/nvim/lua/plugins/lsp.lua | 80 ++++++ nvim/.config/nvim/lua/plugins/telescope.lua | 33 +++ nvim/.config/nvim/lua/plugins/treesitter.lua | 27 ++ nvim/.config/nvim/lua/plugins/ui.lua | 18 ++ 11 files changed, 246 insertions(+), 232 deletions(-) create mode 100644 nvim/.config/nvim/lua/plugins/colorscheme.lua create mode 100644 nvim/.config/nvim/lua/plugins/copilot.lua create mode 100644 nvim/.config/nvim/lua/plugins/core.lua create mode 100644 nvim/.config/nvim/lua/plugins/filetree.lua create mode 100644 nvim/.config/nvim/lua/plugins/git.lua create mode 100644 nvim/.config/nvim/lua/plugins/haskell.lua create mode 100644 nvim/.config/nvim/lua/plugins/lsp.lua create mode 100644 nvim/.config/nvim/lua/plugins/telescope.lua create mode 100644 nvim/.config/nvim/lua/plugins/treesitter.lua create mode 100644 nvim/.config/nvim/lua/plugins/ui.lua diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 1885210..57dd1be 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -38,235 +38,4 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) -require("lazy").setup({ - install = {}, - spec = { - { - 'ndmitchell/ghcid', - config = function(plugin) - vim.g.ghcid_keep_open = true - vim.g.ghcid_placement = 'below' - vim.opt.rtp:append(plugin.dir .. "/plugins/nvim") - end - }, - { - "nbouscal/vim-stylish-haskell" - }, - { - 'nvim-telescope/telescope.nvim', - tag = '0.1.8', - branch = '0.1.x', - dependencies = { - 'nvim-lua/plenary.nvim', - }, - config = function() - local telescope = require('telescope') - local builtin = require('telescope.builtin') - - vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) - vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) - vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) - - telescope.setup({ - defaults = { - sorting_strategy = "ascending", - -- layout_strategy = "bottom_pane", - layout_strategy = "grey", - layout_config = { - prompt_position = "top" - }, - wrap_results = true, - preview = false, - } - }) - - telescope.load_extension('grey') - end - }, - { - 'nvim-treesitter/nvim-treesitter', - dependencies = { - 'nvim-tree/nvim-web-devicons' - }, - config = function() - require('nvim-treesitter.configs').setup({ - ensure_installed = { 'go', 'haskell', 'lua', 'tsx', 'typescript' }, - auto_install = false, - highlight = { enable = true }, - -- autotag = { enable = true } - }) - end - }, - { - 'nvim-tree/nvim-tree.lua', - config = function() - vim.keymap.set("n", "x", "NvimTreeToggle", {}) - - require('nvim-tree').setup({ - view = { - width = 30, - side = "right", - }, - renderer = { - root_folder_label = false, - group_empty = true, - indent_width = 1, - } - }) - end - }, - { - 'lewis6991/gitsigns.nvim', - config = function() - require('gitsigns').setup({ - signcolumn = true, - current_line_blame = true, - }) - end - }, - { "rhysd/vim-clang-format" }, - { - "neovim/nvim-lspconfig", - config = function() - local lspconfig = require('lspconfig') - - -- Language servers - - lspconfig.gopls.setup({}) - lspconfig.templ.setup({}) - - lspconfig.pylsp.setup({}) - lspconfig.svelte.setup({}) - - -- npm install -g typescript typescript-language-server - lspconfig.ts_ls.setup({}) - - -- npm install -g @elm-tooling/elm-language-server - -- npm install -g elm elm-test elm-format - -- npm install -g elm-review - lspconfig.elmls.setup({}) - - lspconfig.gleam.setup({}) - - lspconfig.lua_ls.setup({ - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - }, - diagnostics = { - globals = { 'vim' }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - }, - telemetry = { - enable = false, - }, - }, - }, - }) - - -- brew install rust-analyzer - lspconfig.rust_analyzer.setup({}) - - lspconfig.ccls.setup({ - init_options = { - compilationDatabaseDirectory = "build" - } - }) - - vim.api.nvim_create_autocmd('LspAttach', { - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - - if client:supports_method('textDocument/formatting') then - vim.api.nvim_create_autocmd('BufWritePre', { - buffer = args.buf, - callback = function() - vim.lsp.buf.format({ bufnr = args.buf, id = client.id }) - end, - }) - end - - vim.keymap.set('n', 'e', vim.diagnostic.open_float, { buffer = args.buf }) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { buffer = args.buf }) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, { buffer = args.buf }) - vim.keymap.set('n', 'rr', vim.lsp.buf.references, { buffer = args.buf }) - vim.keymap.set( - 'n', - 'tih', - function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, - { buffer = args.buf }) - end, - }) - end - }, - { - "folke/noice.nvim", - event = "VeryLazy", - dependencies = { - "MunifTanjim/nui.nvim", - "rcarriga/nvim-notify", - }, - config = function() - require('notify').setup({ - timeout = 1000, - max_width = 40, - top_down = false, - render = "wrapped-compact", - }) - end - }, - { 'github/copilot.vim' }, - { - 'windwp/nvim-ts-autotag', - config = function() - require('nvim-ts-autotag').setup({ - opts = { - enable_close = true, - enable_rename = true, - }, - }) - end - }, - { - 'akinsho/toggleterm.nvim', - version = "*", - config = function() - vim.keymap.set('n', 'tt', 'ToggleTerm', { desc = 'Toggle terminal' }) - - vim.api.nvim_create_autocmd({ "TermEnter" }, { - pattern = "term://*toggleterm#*", - command = "tno tt ToggleTerm" - }) - - function _G.set_terminal_keymaps() - local opts = { buffer = 0 } - vim.keymap.set('t', '', [[]], opts) - vim.keymap.set('t', 'jk', [[]], opts) - 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) - vim.keymap.set('t', '', [[]], opts) - end - - vim.api.nvim_create_autocmd({ "TermEnter" }, { - pattern = "term://*toggleterm#*", - command = "lua set_terminal_keymaps()" - }) - - require("toggleterm").setup({ - shade_terminals = false, - }) - end - }, - { - 'yorickpeterse/nvim-grey', - config = function() - vim.cmd('colo grey') - end - } - } -}) +require("lazy").setup("plugins") diff --git a/nvim/.config/nvim/lua/plugins/colorscheme.lua b/nvim/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..c7f43f1 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,8 @@ +return { + { + 'yorickpeterse/nvim-grey', + config = function() + vim.cmd('colo grey') + end + } +} diff --git a/nvim/.config/nvim/lua/plugins/copilot.lua b/nvim/.config/nvim/lua/plugins/copilot.lua new file mode 100644 index 0000000..84835e6 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/copilot.lua @@ -0,0 +1,3 @@ +return { + { 'github/copilot.vim' }, +} diff --git a/nvim/.config/nvim/lua/plugins/core.lua b/nvim/.config/nvim/lua/plugins/core.lua new file mode 100644 index 0000000..0adf095 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/core.lua @@ -0,0 +1,34 @@ +return { + { + 'akinsho/toggleterm.nvim', + version = "*", + config = function() + vim.keymap.set('n', 'tt', 'ToggleTerm', { desc = 'Toggle terminal' }) + + vim.api.nvim_create_autocmd({ "TermEnter" }, { + pattern = "term://*toggleterm#*", + command = "tno tt ToggleTerm" + }) + + function _G.set_terminal_keymaps() + local opts = { buffer = 0 } + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', 'jk', [[]], opts) + 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) + vim.keymap.set('t', '', [[]], opts) + end + + vim.api.nvim_create_autocmd({ "TermEnter" }, { + pattern = "term://*toggleterm#*", + command = "lua set_terminal_keymaps()" + }) + + require("toggleterm").setup({ + shade_terminals = false, + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/plugins/filetree.lua b/nvim/.config/nvim/lua/plugins/filetree.lua new file mode 100644 index 0000000..5edc972 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/filetree.lua @@ -0,0 +1,20 @@ +return { + { + 'nvim-tree/nvim-tree.lua', + config = function() + vim.keymap.set("n", "x", "NvimTreeToggle", {}) + + require('nvim-tree').setup({ + view = { + width = 30, + side = "right", + }, + renderer = { + root_folder_label = false, + group_empty = true, + indent_width = 1, + } + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/plugins/git.lua b/nvim/.config/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..7dc3276 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/git.lua @@ -0,0 +1,11 @@ +return { + { + 'lewis6991/gitsigns.nvim', + config = function() + require('gitsigns').setup({ + signcolumn = true, + current_line_blame = true, + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/plugins/haskell.lua b/nvim/.config/nvim/lua/plugins/haskell.lua new file mode 100644 index 0000000..176a584 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/haskell.lua @@ -0,0 +1,11 @@ +return { + { + 'ndmitchell/ghcid', + config = function(plugin) + vim.g.ghcid_keep_open = true + vim.g.ghcid_placement = 'below' + vim.opt.rtp:append(plugin.dir .. "/plugins/nvim") + end + }, + { "nbouscal/vim-stylish-haskell" }, +} diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..aebba7b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,80 @@ +return { + { + "neovim/nvim-lspconfig", + config = function() + local lspconfig = require('lspconfig') + + -- Language servers + + lspconfig.gopls.setup({}) + lspconfig.templ.setup({}) + + lspconfig.pylsp.setup({}) + lspconfig.svelte.setup({}) + + -- npm install -g typescript typescript-language-server + lspconfig.ts_ls.setup({}) + + -- npm install -g @elm-tooling/elm-language-server + -- npm install -g elm elm-test elm-format + -- npm install -g elm-review + lspconfig.elmls.setup({}) + + lspconfig.gleam.setup({}) + + lspconfig.lua_ls.setup({ + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + }, + diagnostics = { + globals = { 'vim' }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, + }) + + -- brew install rust-analyzer + lspconfig.rust_analyzer.setup({}) + + lspconfig.ccls.setup({ + init_options = { + compilationDatabaseDirectory = "build" + } + }) + + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + + if client:supports_method('textDocument/formatting') then + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({ bufnr = args.buf, id = client.id }) + end, + }) + end + + vim.keymap.set('n', 'e', vim.diagnostic.open_float, { buffer = args.buf }) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, { buffer = args.buf }) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, { buffer = args.buf }) + vim.keymap.set('n', 'rr', vim.lsp.buf.references, { buffer = args.buf }) + vim.keymap.set( + 'n', + 'tih', + function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, + { buffer = args.buf }) + end, + }) + end + }, + +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..d14232b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,33 @@ +return { + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + }, + config = function() + local telescope = require('telescope') + local builtin = require('telescope.builtin') + + vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) + vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) + vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) + + telescope.setup({ + defaults = { + sorting_strategy = "ascending", + -- layout_strategy = "bottom_pane", + layout_strategy = "grey", + layout_config = { + prompt_position = "top" + }, + wrap_results = true, + preview = false, + } + }) + + telescope.load_extension('grey') + end + }, +} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..adee38c --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,27 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + config = function() + require('nvim-treesitter.configs').setup({ + ensure_installed = { 'go', 'haskell', 'lua', 'tsx', 'typescript' }, + auto_install = false, + highlight = { enable = true }, + autotag = { enable = true } + }) + end + }, + { + 'windwp/nvim-ts-autotag', + config = function() + require('nvim-ts-autotag').setup({ + opts = { + enable_close = true, + enable_rename = true, + }, + }) + end + }, +} diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua new file mode 100644 index 0000000..c5140b3 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -0,0 +1,18 @@ +return { + { + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + config = function() + require('notify').setup({ + timeout = 1000, + max_width = 40, + top_down = false, + render = "wrapped-compact", + }) + end + }, +} -- 2.43.0