From 225b1b37f2aae1aba38f4f0672c3f629b1299fe9 Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Sun, 21 Jan 2024 23:32:15 +0100 Subject: [PATCH] feat(nvim): refactor config --- nvim/init.lua | 43 +-- nvim/lazy-lock.json | 32 +- nvim/lua/config/keymaps.lua | 59 ++++ nvim/lua/config/manager.lua | 23 ++ nvim/lua/{ => config}/neovide.lua | 17 +- nvim/lua/{ => config}/options.lua | 24 +- nvim/lua/{utility.lua => config/utils.lua} | 17 +- nvim/lua/keymaps.lua | 59 ---- nvim/lua/plugins.lua | 354 +++++++++++---------- nvim/lua/plugins/haskell-tools.lua | 6 +- nvim/lua/plugins/rust-tools.lua | 4 +- 11 files changed, 330 insertions(+), 308 deletions(-) create mode 100644 nvim/lua/config/keymaps.lua create mode 100644 nvim/lua/config/manager.lua rename nvim/lua/{ => config}/neovide.lua (53%) rename nvim/lua/{ => config}/options.lua (65%) rename nvim/lua/{utility.lua => config/utils.lua} (84%) delete mode 100644 nvim/lua/keymaps.lua diff --git a/nvim/init.lua b/nvim/init.lua index 149da16..036672b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -4,44 +4,23 @@ if vim.loader then end -- Setup default options -require "options" -require "keymaps" +require 'config.options' +require 'config.keymaps' -- Are we inside Neovide? if vim.g.neovide then - require "neovide" + require 'config.neovide' end --- Are we outside VSCode? -if not vim.g.vscode then - -- Bootstrap Lazy - local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" - if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", - lazypath, - }) - end - vim.opt.rtp:prepend(lazypath) +-- Try load package manager +local ok, err = pcall(function() + require 'config.manager' +end) - -- Load lazy - local ok, err = pcall(function() - local plugins = require "plugins" - local lazy = require "lazy" +if not ok and err then + vim.cmd 'colorscheme slate' - lazy.setup(plugins) + vim.schedule(function() + vim.notify(err, vim.log.levels.ERROR) end) - - if not ok and err then - vim.cmd "colorscheme slate" - - vim.schedule(function() - vim.notify(err, vim.log.levels.ERROR) - end) - end end - diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 028681b..419fbbf 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,4 +1,5 @@ { + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, "bufferline.nvim": { "branch": "main", "commit": "6c456b888823d9e4832aa91c482bccd19445c009" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, @@ -7,27 +8,26 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, - "gitsigns.nvim": { "branch": "main", "commit": "4aaacbf5e5e2218fd05eb75703fe9e0f85335803" }, - "haskell-tools.nvim": { "branch": "master", "commit": "6224672ffc44fc1bd95f79792277d95a92a67090" }, + "gitsigns.nvim": { "branch": "main", "commit": "c5ff7628e19a47ec14d3657294cc074ecae27b99" }, + "haskell-tools.nvim": { "branch": "master", "commit": "2faa2c879c82652f1df3974c185901cf93c6367c" }, "kanagawa.nvim": { "branch": "master", "commit": "c19b9023842697ec92caf72cd3599f7dd7be4456" }, - "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, + "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, "lualine.nvim": { "branch": "master", "commit": "566b7036f717f3d676362742630518a47f132fff" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "0989bdf4fdf7b5aa4c74131d7ffccc3f399ac788" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3ba1b92b771f33256b4969d696b82c8ae7075364" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" }, - "mason.nvim": { "branch": "main", "commit": "e110bc3be1a7309617cecd77bfe4bf86ba1b8134" }, - "neo-tree.nvim": { "branch": "v3.x", "commit": "77d9f484b88fd380386b46ed9206e5374d69d9d8" }, - "neodev.nvim": { "branch": "main", "commit": "dde00106b9094f101980b364fae02fd85d357306" }, + "mason.nvim": { "branch": "main", "commit": "bce96d2fd483e71826728c6f9ac721fc9dd7d2cf" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "2f2d08894bbc679d4d181604c16bb7079f646384" }, + "neodev.nvim": { "branch": "main", "commit": "aaeb44589cab39c2545a328661af355622d68479" }, "nui.nvim": { "branch": "main", "commit": "35da9ca1de0fc4dda96c2e214d93d363c145f418" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, - "nvim-dap": { "branch": "master", "commit": "aad46274f09ba29933e4cef2257cdda5ec19cf7a" }, - "nvim-dap-ui": { "branch": "master", "commit": "7e5e16427aaf814dc2d58e1b219def9ef2fa2435" }, - "nvim-lspconfig": { "branch": "master", "commit": "e47ccfae775f0d572ef0f3a7d245f043b259dafc" }, - "nvim-notify": { "branch": "master", "commit": "1576123bff3bed67bc673a3076e591abfe5d8ca9" }, - "nvim-treesitter": { "branch": "master", "commit": "8cd2b230174efbf7b5d9f49fe2f90bda6b5eb16e" }, - "nvim-web-devicons": { "branch": "master", "commit": "584038666b0d8124d452a2e8ea9e38e6d6e56490" }, - "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, - "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, - "rustaceanvim": { "branch": "master", "commit": "d03f72788b81cb311250d9fe0692f3435d609b5a" }, + "nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" }, + "nvim-dap-ui": { "branch": "master", "commit": "a62e86b124a94ad1f34a3f936ea146d00aa096d1" }, + "nvim-lspconfig": { "branch": "master", "commit": "8917d2c830e04bf944a699b8c41f097621283828" }, + "nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" }, + "nvim-treesitter": { "branch": "master", "commit": "94bd4bcc5bbce8334303727627b628ece72e798d" }, + "nvim-web-devicons": { "branch": "master", "commit": "140edfcf25093e8b321d13e154cbce89ee868ca0" }, + "plenary.nvim": { "branch": "master", "commit": "663246936325062427597964d81d30eaa42ab1e4" }, + "rustaceanvim": { "branch": "master", "commit": "b0c03f052d24a2bfc4cc681075c2d81d3c3ac2f7" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..07216ce --- /dev/null +++ b/nvim/lua/config/keymaps.lua @@ -0,0 +1,59 @@ +local utils = require 'config.utils' +local map, augroup, autocmd = utils.keymap, utils.augroup, utils.autocmd +local n, t, nv = map 'n', map 't', map {'n', 'v'} + + +n 'mn' ':Explore ~/.config/nvim/' 'Meta: open Neovim config' + +n 'ex' ':Explore' 'Netrw: open' +n 'hl' ':nohl' 'Hide highlights' + +n 'j' 'gj' 'Move: down by line' +n 'k' 'gk' 'Move: up by line' + +n 'bn' ':bn' 'Buffer: next' +n 'bp' ':bp' 'Buffer: previous' +n 'bd' ':bd' 'Buffer: delete' + +t '' [[]] 'Exit from terminal mode' + +n '' 'h' 'Window: move left' +n '' 'j' 'Window: move down' +n '' 'k' 'Window: move up' +n '' 'l' 'Window: move right' + +-- Diagnostics +n 'e' (vim.diagnostic.open_float) 'Open error diagnostics' +n '[d' (vim.diagnostic.goto_prev) 'Previous diagnostic message' +n ']d' (vim.diagnostic.goto_next) 'Next diagnostic message' +n 'dl' (vim.diagnostic.setloclist) 'Diagnostic: list messages' + +-- LSP +autocmd 'LspAttach' {'LSP actions', group=augroup 'UserLspConfig'} (function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + local function workspaces_list() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end + + local function format() + vim.lsp.buf.format({async = true}) + end + + local buffer = ev.buf + n 'K' (vim.lsp.buf.hover) {'Show hover help', buffer} + n 'gD' (vim.lsp.buf.declaration) {'Go to declaration', buffer} + n 'gd' (vim.lsp.buf.definition) {'Go to definition', buffer} + n 'gi' (vim.lsp.buf.implementation) {'Go to implementation', buffer} + n 'gr' (vim.lsp.buf.references) {'Show references', buffer} + n 'D' (vim.lsp.buf.type_definition) {'Go to type definition', buffer} + n '' (vim.lsp.buf.signature_help) {'Signature help', buffer} + n 'wa' (vim.lsp.buf.add_workspace_folder) {'Add workspace folder', buffer} + n 'wr' (vim.lsp.buf.remove_workspace_folder) {'Remove workspace folder', buffer} + n 'wl' (workspaces_list) {'List workspace folders', buffer} + n 'lr' (vim.lsp.buf.rename) {'Rename identifier', buffer} + nv 'la' (vim.lsp.buf.code_action) {'Show code actions', buffer} + n 'lf' (format) {'Format file', buffer} +end) + diff --git a/nvim/lua/config/manager.lua b/nvim/lua/config/manager.lua new file mode 100644 index 0000000..aaf0742 --- /dev/null +++ b/nvim/lua/config/manager.lua @@ -0,0 +1,23 @@ +local data = vim.fn.stdpath 'data' +local path = data .. '/lazy/lazy.nvim' + + +-- Bootstrap +if not vim.loop.fs_stat(path) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', + path, + } +end +vim.opt.rtp:prepend(path) + +-- Load +local plugins = require 'plugins' +local lazy = require 'lazy' + +-- Init +lazy.setup(plugins) diff --git a/nvim/lua/neovide.lua b/nvim/lua/config/neovide.lua similarity index 53% rename from nvim/lua/neovide.lua rename to nvim/lua/config/neovide.lua index 6deee26..864a1a2 100644 --- a/nvim/lua/neovide.lua +++ b/nvim/lua/config/neovide.lua @@ -4,30 +4,29 @@ local options = { cursor_animation_length = 0.05, } -for key, value in pairs(options) do - vim.g['neovide_' .. key] = value +for key, val in pairs(options) do + vim.g['neovide_' .. key] = val end -- Japanese IME compat local function set_ime(args) - if args.event:match("Enter$") then + if args.event:match 'Enter$' then vim.g.neovide_input_ime = true else vim.g.neovide_input_ime = false end end -local ime_input = vim.api.nvim_create_augroup("ime_input", { clear = true }) +local ime_input = vim.api.nvim_create_augroup('ime_input', { clear = true }) -vim.api.nvim_create_autocmd({ "InsertEnter", "InsertLeave" }, { +vim.api.nvim_create_autocmd({ 'InsertEnter', 'InsertLeave' }, { group = ime_input, - pattern = "*", + pattern = '*', callback = set_ime }) -vim.api.nvim_create_autocmd({ "CmdlineEnter", "CmdlineLeave" }, { +vim.api.nvim_create_autocmd({ 'CmdlineEnter', 'CmdlineLeave' }, { group = ime_input, - pattern = "[/\\?]", + pattern = '[/\\?]', callback = set_ime }) - diff --git a/nvim/lua/options.lua b/nvim/lua/config/options.lua similarity index 65% rename from nvim/lua/options.lua rename to nvim/lua/config/options.lua index 7e04bc2..989d71a 100644 --- a/nvim/lua/options.lua +++ b/nvim/lua/config/options.lua @@ -1,5 +1,5 @@ -local U = require("utility") -local autocmd = U.autocmd +local utils = require 'config.utils' +local autocmd = utils.autocmd local g, opt = vim.g, vim.opt @@ -10,9 +10,9 @@ g.loaded_perl_provider = 0 g.loaded_node_provider = 0 -- General -opt.clipboard = "unnamedplus" -- Use system clipboard +opt.clipboard = 'unnamedplus' -- Use system clipboard opt.swapfile = false -- Don't use swapfiles -opt.completeopt = "menuone,noinsert,noselect" -- Completion behavior +opt.completeopt = 'menuone,noinsert,noselect' -- Completion behavior opt.termguicolors = true -- Indentation @@ -24,19 +24,19 @@ opt.expandtab = true -- Use spaces instead of tabs -- Visual opt.number = true -- Show current line number opt.relativenumber = true -- Show relative line numbers -opt.colorcolumn = "80" -- Show soft char limit +opt.colorcolumn = '80' -- Show soft char limit opt.list = true -- Show punctuation opt.listchars = { -- Punctuation marks - trail = "·", - nbsp = "␣", - tab = "⇥ ", - leadmultispace = "│ ", + trail = '·', + nbsp = '␣', + tab = '⇥ ', + leadmultispace = '│ ', } -- Trailing whitespace -autocmd "BufWritePre" {} (function() - if vim.bo.filetype == "markdown" then return end - vim.cmd([[%s/\s\+$//e]]) +autocmd 'BufWritePre' {} (function() + if vim.bo.filetype == 'markdown' then return end + vim.cmd [[%s/\s\+$//e]] end) -- Additional filetypes diff --git a/nvim/lua/utility.lua b/nvim/lua/config/utils.lua similarity index 84% rename from nvim/lua/utility.lua rename to nvim/lua/config/utils.lua index 6ee899c..28e159e 100644 --- a/nvim/lua/utility.lua +++ b/nvim/lua/config/utils.lua @@ -1,5 +1,6 @@ local M = {} -local def_opts = {noremap = true, silent = true} + +local defaults = { noremap = true, silent = true } ---@class KeymapOpts @@ -19,13 +20,13 @@ function M.keymap(modes) return function(opts) local type = type(opts) local options - if type == "string" then - options = vim.tbl_extend("force", def_opts, {desc=opts}) - elseif type == "table" then + if type == 'string' then + options = vim.tbl_extend('force', defaults, {desc=opts}) + elseif type == 'table' then opts.desc = opts[1] or opts.desc opts.buffer = opts[2] or opts.buffer opts[1], opts[2] = nil, nil - options = vim.tbl_extend("force", def_opts, opts) + options = vim.tbl_extend('force', defaults, opts) end vim.keymap.set(modes, lhs, rhs, options) end @@ -44,9 +45,9 @@ end function M.augroup(opts) local type = type(opts) local name, options - if type == "string" then + if type == 'string' then name, options = opts, {} - elseif type == "table" then + elseif type == 'table' then name, options = opts[1], opts options[1] = nil end @@ -81,7 +82,7 @@ function M.as_extendable(config) ---@param base LazyPluginSpec ---@return LazyPluginSpec return function(base) - return vim.tbl_extend("keep", base, config) + return vim.tbl_extend('keep', base, config) end end diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua deleted file mode 100644 index 1d9c610..0000000 --- a/nvim/lua/keymaps.lua +++ /dev/null @@ -1,59 +0,0 @@ -local U = require("utility") -local map, augroup, autocmd = U.keymap, U.augroup, U.autocmd -local n, t, nv = map 'n', map 't', map {'n', 'v'} - - -n "mn" ":Explore ~/.config/nvim/" "Meta: open Neovim config" - -n "ex" ":Explore" "Netrw: open" -n "hl" ":nohl" "Hide highlights" - -n "j" "gj" "Move: down by line" -n "k" "gk" "Move: up by line" - -n "bn" ":bn" "Buffer: next" -n "bp" ":bp" "Buffer: previous" -n "bd" ":bd" "Buffer: delete" - -t "" [[]] "Exit from terminal mode" - -n "" "h" "Window: move left" -n "" "j" "Window: move down" -n "" "k" "Window: move up" -n "" "l" "Window: move right" - --- Diagnostics -n "e" (vim.diagnostic.open_float) "Open error diagnostics" -n "[d" (vim.diagnostic.goto_prev) "Previous diagnostic message" -n "]d" (vim.diagnostic.goto_next) "Next diagnostic message" -n "dl" (vim.diagnostic.setloclist) "Diagnostic: list messages" - --- LSP -autocmd "LspAttach" {"LSP actions", group=augroup "UserLspConfig"} (function(ev) - -- Enable completion triggered by - vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' - - local function workspaces_list() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end - - local function format() - vim.lsp.buf.format({async = true}) - end - - local buffer = ev.buf - n "K" (vim.lsp.buf.hover) {"Show hover help", buffer} - n "gD" (vim.lsp.buf.declaration) {"Go to declaration", buffer} - n "gd" (vim.lsp.buf.definition) {"Go to definition", buffer} - n "gi" (vim.lsp.buf.implementation) {"Go to implementation", buffer} - n "gr" (vim.lsp.buf.references) {"Show references", buffer} - n "D" (vim.lsp.buf.type_definition) {"Go to type definition", buffer} - n "" (vim.lsp.buf.signature_help) {"Signature help", buffer} - n "wa" (vim.lsp.buf.add_workspace_folder) {"Add workspace folder", buffer} - n "wr" (vim.lsp.buf.remove_workspace_folder) {"Remove workspace folder", buffer} - n "wl" (workspaces_list) {"List workspace folders", buffer} - n "lr" (vim.lsp.buf.rename) {"Rename identifier", buffer} - nv "la" (vim.lsp.buf.code_action) {"Show code actions", buffer} - n "lf" (format) {"Format file", buffer} -end) - diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index f4be6db..5d7f323 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -1,5 +1,5 @@ -local U = require "utility" -local n = U.keymap "n" +local util = require 'config.utils' +local n = util.keymap 'n' ---@type LazySpec @@ -7,138 +7,67 @@ return { -- Theme { - "rebelot/kanagawa.nvim", + 'rebelot/kanagawa.nvim', + enabled = not vim.g.vscode, lazy = false, priority = math.huge, config = function() - vim.cmd "colorscheme kanagawa" + vim.cmd 'colorscheme kanagawa' end, }, -- Status line { - "nvim-lualine/lualine.nvim", + 'nvim-lualine/lualine.nvim', + enabled = not vim.g.vscode, dependencies = { - "nvim-tree/nvim-web-devicons", + 'nvim-tree/nvim-web-devicons', }, config = function() - local lualine = require "lualine" + local lualine = require 'lualine' lualine.setup {} end }, -- Telescope { - "nvim-telescope/telescope.nvim", - branch = "0.1.x", + 'nvim-telescope/telescope.nvim', + enabled = not vim.g.vscode, + branch = '0.1.x', dependencies = { - "nvim-lua/plenary.nvim", - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" } + 'nvim-lua/plenary.nvim', + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } }, config = function() - local telescope = require "telescope" - local builtin = require "telescope.builtin" + local telescope = require 'telescope' + local builtin = require 'telescope.builtin' local ext = telescope.extensions - telescope.load_extension "fzf" - telescope.load_extension "notify" + telescope.load_extension 'fzf' + telescope.load_extension 'notify' telescope.setup { extensions = { fzf = { fuzzy = true, override_generic_sorter = true, override_file_sorter = true, - case_mode = "smart_case", + case_mode = 'smart_case', } } } - n "ff" (builtin.find_files) "Telescope: find files" - n "fb" (builtin.buffers) "Telescope: find buffers" - n "fg" (builtin.live_grep) "Telescope: grep content" - n "fh" (builtin.help_tags) "Telescope: search docs" - n "fn" (ext.notify.notify) "Telescope: find notifications" + n 'ff' (builtin.find_files) 'Telescope: find files' + n 'fb' (builtin.buffers) 'Telescope: find buffers' + n 'fg' (builtin.live_grep) 'Telescope: grep content' + n 'fh' (builtin.help_tags) 'Telescope: search docs' + n 'fn' (ext.notify.notify) 'Telescope: find notifications' end, }, - -- Shortcut hints - { - "folke/which-key.nvim", - event = "VeryLazy", - init = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - end, - opts = {} - }, - - -- Notifications - { - "rcarriga/nvim-notify", - config = function() - vim.notify = require "notify" - end - }, - - -- File tree - { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "MunifTanjim/nui.nvim", - }, - }, - - -- Bufferline - { - "akinsho/bufferline.nvim", - version = "*", - dependencies = { - "nvim-tree/nvim-web-devicons" - }, - config = function() - local config = require "bufferline" - config.setup() - end - }, - - -- Git diffviewer - { - "sindrets/diffview.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - }, - }, - - -- Git signs - { - "lewis6991/gitsigns.nvim", - config = function() - local gitsigns = require "gitsigns" - gitsigns.setup() - end, - }, - - { - "andweeb/presence.nvim", - config = function() - local presence = require "presence" - - presence.setup { - main_image = "file", - show_time = false, - buttons = false, - } - end - }, - -- Treesitter { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', config = function() local configs = require 'nvim-treesitter.configs' @@ -149,32 +78,41 @@ return { ignore_install = {}, ensure_installed = { -- neovim - "vimdoc", "lua", "query", + 'vimdoc', 'lua', 'query', -- data - "json", "xml", "yaml", "toml", "dhall", + 'json', 'xml', 'yaml', 'toml', 'dhall', -- markdown - "markdown", "markdown_inline", + 'markdown', 'markdown_inline', -- latex - "latex", "bibtex", + 'latex', 'bibtex', -- git - "gitcommit", "gitignore", "diff", + 'gitcommit', 'gitignore', 'diff', -- misc - "comment", "dockerfile", "regex", + 'comment', 'dockerfile', 'regex', -- shell - "bash", + 'bash', -- julia - "julia", + 'julia', -- python - "python", + 'python', -- rust - "rust", + 'rust', -- webdev - "html", "css", "scss", "javascript", "jsdoc", "typescript", "tsx", "astro", "svelte", + 'html', 'css', 'scss', 'javascript', 'jsdoc', 'typescript', 'tsx', 'astro', 'svelte', -- haskell - "haskell", "purescript", "nix", + 'haskell', 'purescript', 'nix', }, highlight = { enable = true }, indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + scope_incremental = '', + node_incremental = '', + node_decremental = '', + }, + }, } end, init = function() @@ -185,14 +123,88 @@ return { end, }, + -- Git signs + { + 'lewis6991/gitsigns.nvim', + enabled = not vim.g.vscode, + config = function() + local gitsigns = require 'gitsigns' + gitsigns.setup() + end, + }, + + -- Comments + { + 'numToStr/Comment.nvim', + config = true, + }, + + -- Shortcut hints + { + 'folke/which-key.nvim', + enabled = not vim.g.vscode, + event = 'VeryLazy', + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = {} + }, + + -- Notifications + { + 'rcarriga/nvim-notify', + enabled = not vim.g.vscode, + config = function() + vim.notify = require 'notify' + end + }, + + -- File tree + { + 'nvim-neo-tree/neo-tree.nvim', + enabled = not vim.g.vscode, + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + 'MunifTanjim/nui.nvim', + }, + }, + + -- Bufferline + { + 'akinsho/bufferline.nvim', + enabled = not vim.g.vscode, + version = '*', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + config = function() + local config = require 'bufferline' + config.setup() + end + }, + + -- Git diffviewer + { + 'sindrets/diffview.nvim', + enabled = not vim.g.vscode, + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', + }, + }, + -- LS configs { - "neovim/nvim-lspconfig", + 'neovim/nvim-lspconfig', + enabled = not vim.g.vscode, opts = { inlay_hints = { enabled = true }, }, config = function() - local lsp = require "lspconfig" + local lsp = require 'lspconfig' lsp.nushell.setup {} end, @@ -200,60 +212,64 @@ return { -- Snippet engine { - "L3MON4D3/LuaSnip", - version = "2.*", + 'L3MON4D3/LuaSnip', + version = '2.*', }, -- Completion - require "plugins.nvim-cmp" { - "hrsh7th/nvim-cmp", + require 'plugins.nvim-cmp' { + 'hrsh7th/nvim-cmp', dependencies = { - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-nvim-lsp", - "saadparwaiz1/cmp_luasnip", + 'hrsh7th/cmp-cmdline', + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-nvim-lsp', + 'saadparwaiz1/cmp_luasnip', }, }, -- Debugger adapter support { - "mfussenegger/nvim-dap", + 'mfussenegger/nvim-dap', + enabled = not vim.g.vscode, config = function() - local dap = require "dap" + local dap = require 'dap' - n "b" (dap.toggle_breakpoint) "DAP: Toggle breakpoint" + n 'b' (dap.toggle_breakpoint) 'DAP: Toggle breakpoint' end, }, -- Debugger UI - require "plugins.nvim-dap-ui" { - "rcarriga/nvim-dap-ui", + require 'plugins.nvim-dap-ui' { + 'rcarriga/nvim-dap-ui', + enabled = not vim.g.vscode, dependencies = { - "mfussenegger/nvim-dap", + 'mfussenegger/nvim-dap', }, }, -- Mason { - "williamboman/mason.nvim", + 'williamboman/mason.nvim', + enabled = not vim.g.vscode, config = function() - local mason = require "mason" + local mason = require 'mason' mason.setup() end, }, -- Automatic LSP server setup for Mason { - "williamboman/mason-lspconfig.nvim", + 'williamboman/mason-lspconfig.nvim', + enabled = not vim.g.vscode, dependencies = { - "williamboman/mason.nvim", - "neovim/nvim-lspconfig", + 'williamboman/mason.nvim', + 'neovim/nvim-lspconfig', }, config = function() - local config = require "mason-lspconfig" - local lsp = require "lspconfig" - local cmp = require "cmp_nvim_lsp" + local config = require 'mason-lspconfig' + local lsp = require 'lspconfig' + local cmp = require 'cmp_nvim_lsp' local noop = function() end @@ -262,19 +278,19 @@ return { -- NOTE -- Haskell: Managed by GHCup ensure_installed = { - "lua_ls", -- Lua - "rust_analyzer", -- Rust - "bashls", -- Bash - "html", -- HTML - "cssls", -- CSS / SCSS - "tsserver", -- TypeScript - "astro", -- Astro - "svelte", -- Svelte - "pyright", -- Python - "rnix", -- Nix - "purescriptls", -- Purescript - "ltex", -- Literate - LaTeX, Markdown, etc. - "julials", -- Julia + 'lua_ls', -- Lua + 'rust_analyzer', -- Rust + 'bashls', -- Bash + 'html', -- HTML + 'cssls', -- CSS / SCSS + 'tsserver', -- TypeScript + 'astro', -- Astro + 'svelte', -- Svelte + 'pyright', -- Python + 'rnix', -- Nix + 'purescriptls', -- Purescript + 'ltex', -- Literate - LaTeX, Markdown, etc. + 'julials', -- Julia }, } @@ -292,18 +308,19 @@ return { -- Automatic debugger install { - "jay-babu/mason-nvim-dap.nvim", + 'jay-babu/mason-nvim-dap.nvim', + enabled = not vim.g.vscode, dependencies = { - "mfussenegger/nvim-dap", - "williamboman/mason.nvim", + 'mfussenegger/nvim-dap', + 'williamboman/mason.nvim', }, config = function() - local config = require "mason-nvim-dap" + local config = require 'mason-nvim-dap' config.setup { automatic_installation = true, ensure_installed = { - "codelldb", + 'codelldb', }, } end, @@ -311,19 +328,20 @@ return { -- Tools for Neovim { - "folke/neodev.nvim", - ft = "lua", + 'folke/neodev.nvim', + enabled = not vim.g.vscode, + ft = 'lua', dependencies = { - "neovim/nvim-lspconfig", + 'neovim/nvim-lspconfig', }, config = function() - local neodev = require "neodev" - local lsp = require "lspconfig" + local neodev = require 'neodev' + local lsp = require 'lspconfig' neodev.setup() lsp.lua_ls.setup { settings = { - Lua = { completion = { callSnippet = "Replace" } } + Lua = { completion = { callSnippet = 'Replace' } } } } end @@ -331,22 +349,24 @@ return { -- Tools for Rust { - "mrcjkb/rustaceanvim", - version = "^3", - ft = { "rust" }, + 'mrcjkb/rustaceanvim', + enabled = not vim.g.vscode, + version = '^3', + ft = { 'rust' }, init = function() require 'plugins.rust-tools' end }, -- Tools for Haskell - require "plugins.haskell-tools" { - "mrcjkb/haskell-tools.nvim", - version = "^3", - ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + require 'plugins.haskell-tools' { + 'mrcjkb/haskell-tools.nvim', + enabled = not vim.g.vscode, + version = '^3', + ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' }, dependencies = { - "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim", + 'nvim-lua/plenary.nvim', + 'nvim-telescope/telescope.nvim', }, }, diff --git a/nvim/lua/plugins/haskell-tools.lua b/nvim/lua/plugins/haskell-tools.lua index aca6bfa..7839fa4 100644 --- a/nvim/lua/plugins/haskell-tools.lua +++ b/nvim/lua/plugins/haskell-tools.lua @@ -1,5 +1,5 @@ -local U = require 'utility' -local n = U.keymap 'n' +local utils = require 'config.utils' +local n = utils.keymap 'n' ---@param buffer number @@ -24,7 +24,7 @@ local function on_attach(_, buffer, ht) end -return U.as_extendable { +return utils.as_extendable { init = function() vim.g.haskell_tools = { ---@type HaskellLspClientOpts` diff --git a/nvim/lua/plugins/rust-tools.lua b/nvim/lua/plugins/rust-tools.lua index 5331e8a..f2f63ad 100644 --- a/nvim/lua/plugins/rust-tools.lua +++ b/nvim/lua/plugins/rust-tools.lua @@ -1,5 +1,5 @@ -local util = require 'utility' -local n = util.keymap 'n' +local util = require 'config.utils' +local n = util.keymap 'n' vim.g.rustaceanvim = function()