diff --git a/nvim/lua/user/keymaps.lua b/nvim/lua/user/keymaps.lua index f493a57..60ba2d1 100644 --- a/nvim/lua/user/keymaps.lua +++ b/nvim/lua/user/keymaps.lua @@ -25,6 +25,9 @@ vim.keymap.set('n', '', [[:m +1v=]], { silent = true, desc = 'move curr vim.keymap.set('v', '', [[:m '<-2gv=gv]], { silent = true, desc = 'move current selection one line up' }) vim.keymap.set('v', '', [[:m '>+1gv=gv]], { silent = true, desc = 'move current selection one line down' }) +-- Undo tree +vim.keymap.set('n', 'u', [[:UndotreeToggle:UndotreeFocus]], { desc = 'Toggle undotree' }) + -- -- Editing - formatting -- @@ -43,10 +46,6 @@ vim.keymap.set('x', 'fha', [[:s/0x\(\x\{1\}\X\)/0x0\1/g]], vim.keymap.set('x', 'fhn', [[:s/\(\(0x\x\{1,2\}, \)\{8\}\)/\1\r/g]], { desc = "Format a comma separated hex list into 8 bytes per line." }) --- Case formatting -vim.keymap.set('x', 'fc', "noop", { desc = "Case" }) -vim.keymap.set("x", "fcsc", [[:s/\%V\([a-z]\+\)_\?/\u\1/g]], - { desc = "Convert text from snake_case to CamelCase" }) -- -- Editing - Copy / Paste diff --git a/nvim/lua/user/plugins/core.lua b/nvim/lua/user/plugins/core.lua deleted file mode 100644 index 072a944..0000000 --- a/nvim/lua/user/plugins/core.lua +++ /dev/null @@ -1,66 +0,0 @@ -local icons = require('user.icons') - -return { - { import = "user.plugins.core.colorscheme" }, - { - "williamboman/mason.nvim", - build = ":MasonUpdate", - cmd = "Mason", - opts_extend = { "ensure_installed" }, - opts = {}, - config = function(_, opts) - require("mason").setup(opts) - end - }, - -- Dashboard - { - "goolord/alpha-nvim", - config = function() - local alpha = require'alpha' - local dashboard = require'alpha.themes.dashboard' - - dashboard.section.header.val = { - [[ __ ]], - [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], - [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], - [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], - [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], - [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], - } - - dashboard.section.buttons.val = { - dashboard.button("e", icons.files.text .. " New file" , ":ene startinsert"), - dashboard.button("s", icons.search .. " Search files" , ":Telescope find_files"), - dashboard.button("o", icons.search .. " Old files" , ":Telescope oldfiles"), - dashboard.button("q", icons.close .. " Quit" , ":qa"), - } - - alpha.setup(dashboard.config) - end, - }, - -- Icons - { - 'nvim-tree/nvim-web-devicons', - opts = { - override = { - php = { - icon = icons.filetypes.php, - color = "#4F5B93", - name = "Php" - } - }, - override_by_filename = { - ["artisan"] = { - icon = icons.filetypes.laravel, - color = "#f05340", - name = "LaravelArtisan" - }, - ["phpunit.xml"] = { - icon = icons.filetypes.phpunit, - color = "#0d6efd", - name = "PhpUnit" - } - } - } - } -} diff --git a/nvim/lua/user/plugins/core/colorscheme.lua b/nvim/lua/user/plugins/core/colorscheme.lua deleted file mode 100644 index 4c11770..0000000 --- a/nvim/lua/user/plugins/core/colorscheme.lua +++ /dev/null @@ -1,256 +0,0 @@ - -local options = { - flavour = "mocha", - transparent_background = not vim.g.neovide, - color_overrides = { - mocha = { - base = "#0E1019", - mantle = "#0D0F17", - crust = "#0C0D14", - surface0 = "#1a1c2d", - surface1 = "#343959", - surface2 = "#41476F", - overlay0 = "#3F4256", - overlay1 = "#5B5F7C", - overlay2 = "#767BA0", - - text = "#eceef4", - }, - }, - no_italic = true, - no_bold = true, - custom_highlights = function(colors) - return { - CursorLine = { bg = colors.surface0 }, - SignColumnSep = { bg = colors.surface0, fg = colors.lavender }, - - Visual = { bg = colors.surface1 }, - FoldColumn = { fg = colors.surface2 }, - - -- Floating windows - NormalFloat = { fg = colors.text, bg = colors.crust }, - FloatTitle = { fg = colors.base, bg = colors.blue }, - FloatBorder = { fg = colors.surface1, bg = colors.crust }, - - -- Window separator - WinSeparator = { fg = colors.surface0 }, - - -- Menus - Pmenu = { link = "NormalFloat" }, - PmenuSel = { bg = colors.surface2 }, - PmenuSbar = { link = "Pmenu" }, - PmenuThumb = { link = "PmenuSel" }, - - -- NoiceMini = { link = "NormalFloat" }, - WhichKeyFloat = { link = "Pmenu" }, - - -- indent lines - IblScope = { fg = colors.surface0 }, - - -- Search matches - IncSearch = { bg = colors.yellow }, - - -- Autocomplete window - CmpItemAbbr = { fg = colors.overlay2 }, - CmpItemKindText = { fg = colors.text }, - - -- CmpKind - CmpItemKindBladeNav = { fg = "#f55247" }, - - -- telescope - TelescopeNormal = { link = "NormalFloat" }, - TelescopeBorder = { link = "FloatBorder" }, - TelescopeTitle = { link = "FloatTitle" }, - TelescopePromptNormal = { bg = colors.mantle }, - TelescopePromptPrefix = { fg = colors.mauve }, - TelescopePromptBorder = { fg = colors.mantle, bg = colors.mantle }, - TelescopePreviewTitle = { fg = colors.crust, bg = colors.mauve }, - TelescopeResultsNormal = { fg = colors.text, bg = colors.crust }, - TelescopeResultsClass = { link = "CmpItemKindClass" }, - TelescopeResultsInterface = { link = "CmpItemKindInterface" }, - TelescopeResultsField = { link = "CmpItemKindField" }, - TelescopeResultsFunction = { link = "CmpItemKindFunction" }, - TelescopeResultsMethod = { link = "CmpItemKindMethod" }, - TelescopeResultsNumber = { link = "CmpItemKindNumber" }, - TelescopeResultsStruct = { link = "CmpItemKindStruct" }, - TelescopeResultsConstant = { link = "CmpItemKindConstant" }, - TelescopeResultsOperator = { link = "CmpItemKindOperator" }, - TelescopeResultsVariable = { link = "CmpItemKindVariable" }, - TelescopeResultsIdentifier = { link = "CmpItemKindIdentifier" }, - TelescopeMatching = { fg = colors.lavender }, - TelescopeSelection = { fg = colors.text, bg = colors.surface1 }, - TelescopeIndicatorModified = { fg = colors.yellow }, - TelescopeIndicatorReadonly = { fg = colors.red }, - TelescopeIndicatorHidden = { link = "TelescopeResultsComment" }, - - -- Ufo - UfoFoldedEllipsis = { link = "Comment" }, - - -- Statusline - - -- Something resets StatusLine highlight background, so use another one for now :) - -- StatusLine = { fg = colors.text, bg = colors.crust }, - StatusLineLualine = { fg = colors.text, bg = colors.crust }, - - StatusLineNormal = { link = "StatusLineLualine" }, - StatusLineSeparator = { fg = colors.rosewater, bg = colors.crust }, - StatusLineInsert = { fg = colors.base, bg = colors.blue }, - StatusLineVisual = { fg = colors.base, bg = colors.mauve }, - StatusLineCommand = { fg = colors.base, bg = colors.yellow }, - StatusLineReplace = { fg = colors.base, bg = colors.maroon }, - - -- Neotree - NeoTreeTabActive = { bg = colors.surface2, fg = colors.lavender }, - NeoTreeTabInactive = { bg = colors.crust, fg = colors.surface2 }, - NeoTreeTabSeparatorActive = { fg = colors.base, bg = colors.surface2 }, - NeoTreeTabSeparatorInactive = { fg = colors.base, bg = colors.crust }, - NeoTreeFileIcon = { link = "Normal" }, - NeoTreeModified = { fg = colors.yellow }, - NeoTreeWinSeparator = { link = "WinSeparator" }, - - -- BlinkCmp - BlinkCmpLabel = { link = 'CmpItemAbbr' }, - BlinkCmpLabelMatch = { link = 'CmpItemAbbrMatch' }, - BlinkCmpLabelDeprecated = { link = 'CmpItemAbbrDeprecated'}, - BlinkCmpLabelDetail = { link = 'CmpItemMenu' }, - BlinkCmpLabelDescription = { link = 'CmpItemMenu' }, - - BlinkCmpSource = { link = 'CmpItemMenu' }, - BlinkCmpKind = { link = 'CmpItemKind' }, - BlinkCmpKindText = { link = "CmpItemKindText" }, - BlinkCmpKindMethod = { link = "CmpItemKindMethod" }, - BlinkCmpKindFunction = { link = "CmpItemKindFunction" }, - BlinkCmpKindConstructor = { link = "CmpItemKindConstructor" }, - BlinkCmpKindField = { link = "CmpItemKindField" }, - BlinkCmpKindVariable = { link = "CmpItemKindVariable" }, - BlinkCmpKindClass = { link = "CmpItemKindClass" }, - BlinkCmpKindInterface = { link = "CmpItemKindInterface" }, - BlinkCmpKindModule = { link = "CmpItemKindModule" }, - BlinkCmpKindProperty = { link = "CmpItemKindProperty" }, - BlinkCmpKindUnit = { link = "CmpItemKindUnit" }, - BlinkCmpKindValue = { link = "CmpItemKindValue" }, - BlinkCmpKindEnum = { link = "CmpItemKindEnum" }, - BlinkCmpKindKeyword = { link = "CmpItemKindKeyword" }, - BlinkCmpKindSnippet = { link = "CmpItemKindSnippet" }, - BlinkCmpKindColor = { link = "CmpItemKindColor" }, - BlinkCmpKindFile = { link = "CmpItemKindFile" }, - BlinkCmpKindReference = { link = "CmpItemKindReference" }, - BlinkCmpKindFolder = { link = "CmpItemKindFolder" }, - BlinkCmpKindEnumMember = { link = "CmpItemKindEnumMember" }, - BlinkCmpKindConstant = { link = "CmpItemKindConstant" }, - BlinkCmpKindStruct = { link = "CmpItemKindStruct" }, - BlinkCmpKindEvent = { link = "CmpItemKindEvent" }, - BlinkCmpKindOperator = { link = "CmpItemKindOperator" }, - BlinkCmpKindTypeParameter = { link = "CmpItemKindTypeParameter" }, - - -- Neotest - NeoTestWinSelect = { fg = colors.mauve }, - NeoTestIndent = { fg = colors.surface1 }, - NeoTestExpandMarker = { link = "NeoTestIndent" }, - NeoTestAdapterName = { fg = colors.mauve }, - NeoTestFile = { fg = colors.lavender }, - NeoTestDir = { fg = colors.blue }, - NeoTestTarget = { fg = colors.blue }, - NeoTestNamespace = { fg = colors.mauve }, - NeoTestPassed = { fg = colors.green }, - NeoTestFailed = { fg = colors.red }, - NeoTestSkipped = { fg = colors.blue }, - NeoTestRunning = { fg = colors.yellow }, - NeoTestWatching = { fg = colors.yellow }, - NeoTestMarked = { fg = colors.orange }, - - -- Diagnostics - DiagnosticUnderlineInfo = { style = {"undercurl"} }, - DiagnosticUnderlineHint = { style = {"undercurl"} }, - DiagnosticUnderlineWarn = { style = {"undercurl"} }, - DiagnosticUnderlineError = { style = {"undercurl"} }, - - -- Markdown rendering - RenderMarkdownCode = { bg = colors.crust }, - RenderMarkdownCodeInline = { fg = colors.rosewater, bg = colors.crust }, - - -- Syntax - PreProc = { fg = colors.mauve }, - Operator = { fg = colors.flamingo }, - Function = { link = "@text" }, - Delimiter = { link = "Operator" }, - Keyword = { fg = colors.yellow }, - Include = { link = "Keyword" }, - Repeat = { link = "Keyword" }, - Conditional = { link = "Keyword" }, - Type = { fg = colors.blue }, - Label = { link = "String" }, - String = { fg = colors.lavender }, - Exception = { link = "Keyword" }, - - -- Treesitter tokens - ["@constructor"] = { link = "Function" }, - ["@variable"] = { fg = colors.green }, - ["@variable.builtin"] = { link = "@variable" }, - ["@variable.parameter"] = { link = "@parameter" }, - ["@variable.member"] = { link = "@variable" }, - ["@parameter"] = { link = "@variable" }, - ["@keyword.function"] = { link = "Keyword" }, - ["@keyword.return"] = { link = "Keyword" }, - ["@keyword.operator"] = { link = "Keyword" }, - ["@property"] = { link = "@variable" }, - ["@tag"] = { link = "Keyword" }, - ["@tag.delimiter"] = { link = "@text" }, - ["@module"] = { link = "@text" }, - ["@namespace"] = { link = "@keyword" }, - ["@punctuation.bracket"] = { link = "@punctuation" }, - - -- LSP - ["@lsp.type.property"] = { link = "@variable" }, - ["@lsp.type.namespace.go"] = { fg = colors.rosewater }, - - -- Bash - ["@variable.parameter.bash"] = { fg = colors.rosewater }, - - -- Makefile - ["@function.make"] = { link = "Keyword" }, - ["@string.special.symbol.make"] = { link = "@variable" }, - - -- Markup - ["@markup.raw"] = { link = "@text" }, - ["@markup.strong"] = { fg = colors.blue }, - ["@markup.italic"] = { fg = colors.green }, - - -- PHP - ["@keyword.import.php"] = { link = "@keyword" }, - ["@function.builtin.php"] = { fg = colors.blue }, - ["@class.name.php"] = { link = "@text" }, - ["@class.inherit.name.php"] = { link = "@text" }, - ["@class.implements.name.php"] = { link = "@text" }, - ["@interface.name.php"] = { link = "@text" }, - ["@namespace.name.php"] = { link = "@text" }, - ["@namespace.alias.name.php"] = { link = "@text" }, - ["@use.trait.name.php"] = { link = "@text" }, - - -- Blade - ["@tag.blade"] = { fg = colors.mauve }, - } - end, - integrations = { - cmp = true, - treesitter = true, - neotree = true, - -- barbar = true, - -- noice = true, - telescope = { - enabled = true, - }, - } -} - -return { - "catppuccin/nvim", - name = "catppuccin", - lazy = false, - priority = 1000, - opts = options, - config = function(_, opts) - require("catppuccin").setup(opts) - vim.cmd.colorscheme("catppuccin") - end, -} diff --git a/nvim/lua/user/plugins/editor.lua b/nvim/lua/user/plugins/editor.lua index 1267f70..b62ac03 100644 --- a/nvim/lua/user/plugins/editor.lua +++ b/nvim/lua/user/plugins/editor.lua @@ -1,172 +1,30 @@ -local icons = require('user.icons') + +-- +-- This functions include plugins that adds editing functionality +-- to the editor in some way. +-- return { { import = "user.plugins.editor.treesitter" }, - { 'echasnovski/mini.pairs', version = '*', opts = {}}, - { 'echasnovski/mini.ai', version = '*', opts = {}}, - { 'echasnovski/mini.surround', version = '*', opts ={}}, - { - "mbbill/undotree", - event = { "BufReadPre", "BufNewFile" }, - }, - -- color highlight in documents - { - 'brenoprata10/nvim-highlight-colors', - opts = { - render = 'virtual', - virtual_symbol_position = 'eol', - virtual_symbol_prefix = '', - virtual_symbol_suffix = '', - } - }, - { - "folke/todo-comments.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { - signs = false, - keywords = { - TODO = { color = "warning" }, - }, - highlight = { - keyword = 'fg', - } - } - }, - { - "pnx/mini.bufremove", - opts = { - empty_buf = "Alpha" - }, - }, - { - "lukas-reineke/indent-blankline.nvim", - main = "ibl", - opts = { - debounce = 10, - indent = { - char = icons.indent, - }, - scope = { - enabled = false, - }, - exclude = { - filetypes = { - "help", - "dashboard", - }, - }, - }, - config = function(_, opts) - require("ibl").setup(opts) - - local hooks = require("ibl.hooks") - hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_tab_indent_level) - hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) - end, - }, -- Better folds { import = "user.plugins.editor.ufo" }, - -- Better status column - { - "luukvbaal/statuscol.nvim", - event = { "BufReadPre", "BufNewFile", "BufAdd" }, - opts = function() - local builtin = require("statuscol.builtin") - return { - -- Align current relative number to the right. - relculright = true, - ft_ignore = { - 'help', - 'alpha' - }, - segments = { - { - click = "v:lua.ScSa", - sign = { - namespace = { "gitsigns" }, - maxwidth = 1, - colwidth = 1, - foldclosed = true, - } - }, - { - click = "v:lua.ScSa", - sign = { - name = { ".*" }, - namespace = { ".*" }, - maxwidth = 1, - foldclosed = true, - }, - }, - { - text = { " ", builtin.lnumfunc, " " }, - click = "v:lua.ScLa", - }, - { - text = { builtin.foldfunc, " " }, - condition = { true, function (args) return args.fold.width > 0 end }, - click = "v:lua.ScFa" - }, - { - text = { - function(args) - local pos = vim.api.nvim_win_get_cursor(args.win) - return (args.lnum == pos[1] and "%#SignColumnSep#" or "")..icons.signcolum.separator - end, - }, - }, - } - } - end, - }, - { import = "user.plugins.editor.gitsigns" }, - -- Formatting - { - 'stevearc/conform.nvim', - opts = { - default_format_opts = { - lsp_format = "fallback" - } - }, - init = function() - vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" - user.formatter = function(args) - local range = nil - if args.count ~= -1 then - local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] - range = { - start = { args.line1, 0 }, - ["end"] = { args.line2, end_line:len() }, - } - end - require("conform").format({ async = true, range = range }) - end - end - }, - { import = "user.plugins.editor.finder" }, - { import = "user.plugins.editor.autocomplete" }, - -- Snippets - { - "L3MON4D3/LuaSnip", - lazy = true, - build = "make install_jsregexp", - dependencies = { - { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - }, - opts = {}, - config = function(_, opts) - require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" }) - require("luasnip").setup(opts) - end, - }, + + -- Edit history + { "mbbill/undotree", event = { "BufReadPre", "BufNewFile" } }, + + -- Autopairs + { 'echasnovski/mini.pairs', version = '*', opts = {}}, + + -- Better text objects. + { 'echasnovski/mini.ai', version = '*', opts = {}}, + + -- I use this for crc,crs,crm (etc) binds to change between cases. + { 'tpope/vim-abolish' }, + -- { - -- "m4xshen/hardtime.nvim", - -- dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim" }, - -- opts = {} + -- "pnx/mini.bufremove", + -- opts = { + -- empty_buf = "Alpha" + -- }, -- }, } diff --git a/nvim/lua/user/plugins/editor/autocomplete.lua b/nvim/lua/user/plugins/editor/autocomplete.lua deleted file mode 100644 index e08b578..0000000 --- a/nvim/lua/user/plugins/editor/autocomplete.lua +++ /dev/null @@ -1,107 +0,0 @@ -local icons = require('user.icons') - -return { - 'saghen/blink.cmp', - lazy = false, - version = "*", - build = 'cargo build --release', - dependencies = { - { "xzbdmw/colorful-menu.nvim" }, - { 'L3MON4D3/LuaSnip', version = 'v2.*' }, - }, - opts = { - keymap = { - [''] = { 'select_prev', 'fallback' }, - [''] = { 'select_next', 'fallback' }, - [''] = { 'select_prev', 'fallback' }, - [''] = { 'select_next', 'fallback' }, - [''] = { - function(cmp) - if cmp.snippet_active() then - return cmp.accept() - else - return cmp.select_prev() - end - end, - 'snippet_backward', - 'fallback' - }, - - [''] = { - function(cmp) - if cmp.snippet_active() then - return cmp.accept() - else - return cmp.select_next() - end - end, - 'snippet_forward', - 'fallback' - }, - [''] = { 'accept', 'fallback' }, - }, - appearance = { - nerd_font_variant = 'mono', - kind_icons = icons.symbols - }, - sources = { - default = function(_) - local success, node = pcall(vim.treesitter.get_node) - if success and node and vim.tbl_contains({ 'comment', 'line_comment', 'block_comment' }, node:type()) then - return { 'buffer' } - else - return { 'lsp', 'path', 'snippets', 'buffer' } - end - end - }, - snippets = { - preset = 'luasnip', - expand = function(snippet) require('luasnip').lsp_expand(snippet) end, - active = function(filter) - if filter and filter.direction then - return require('luasnip').jumpable(filter.direction) - end - return require('luasnip').in_snippet() - end, - jump = function(direction) require('luasnip').jump(direction) end, - }, - completion = { - menu = { - min_width = 18, - winblend = 10, - draw = { - columns = { - { "kind_icon" }, - { "label", "source_name", gap = 1 }, - }, - components = { - label = { - text = function(ctx) - return require("colorful-menu").blink_components_text(ctx) - end, - highlight = function(ctx) - return require("colorful-menu").blink_components_highlight(ctx) - end, - }, - }, - } - }, - documentation = { - auto_show = true, - window = { - winblend = 10 - } - }, - ghost_text = { - enabled = true, - } - }, - signature = { - enabled = true, - window = { - scrollbar = false, - winblend = 10, - } - } - } -} diff --git a/nvim/lua/user/plugins/editor/gitsigns.lua b/nvim/lua/user/plugins/editor/gitsigns.lua deleted file mode 100644 index 266ea0a..0000000 --- a/nvim/lua/user/plugins/editor/gitsigns.lua +++ /dev/null @@ -1,40 +0,0 @@ -local icons = require('user.icons').diff_gutter - -return { - "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - { - "folke/which-key.nvim", - optional = true, - opts = { - defaults = { - ["g"] = { name = "+git" }, - }, - }, - }, - }, - opts = { - signs = { - add = { text = icons.add }, - delete = { text = icons.delete }, - change = { text = icons.change }, - untracked = { text = icons.untracked }, - topdelete = { text = icons.delete }, - changedelete = { text = icons.change }, - }, - signs_staged = { - add = { text = icons.add }, - delete = { text = icons.delete }, - change = { text = icons.change }, - topdelete = { text = icons.delete }, - changedelete = { text = icons.change }, - }, - diff_opts = { - internal = true - }, - preview_config = { - border = { " " }, - } - }, -} diff --git a/nvim/lua/user/plugins/editor/treesitter.lua b/nvim/lua/user/plugins/editor/treesitter.lua index de964a1..865529d 100644 --- a/nvim/lua/user/plugins/editor/treesitter.lua +++ b/nvim/lua/user/plugins/editor/treesitter.lua @@ -1,85 +1,75 @@ return { - { - "nvim-treesitter/nvim-treesitter", - build = function() - require("nvim-treesitter.install").update({ with_sync = true }) - end, - opts_extend = { "ensure_installed" }, - opts = { - -- Default parsers. - ensure_installed = { - -- VIM stuff - "vim", - "vimdoc", - "query", + "nvim-treesitter/nvim-treesitter", + build = function() + require("nvim-treesitter.install").update({ with_sync = true }) + end, + opts_extend = { "ensure_installed" }, + opts = { + -- Default parsers. + ensure_installed = { + -- VIM stuff + "vim", + "vimdoc", + "query", - -- Common config languages - "json", - "jsonc", - "yaml", - "toml", - "xml", - "kdl", + -- Common config languages + "json", + "jsonc", + "yaml", + "toml", + "xml", + "kdl", - -- misc - "comment", - "regex", - "re2c", - "xresources", - "sql", - "csv", - "ssh_config", - "printf", - "nginx", - }, - - auto_install = true, - - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - - indent = { - enable = true, - }, + -- misc + "comment", + "regex", + "re2c", + "xresources", + "sql", + "csv", + "ssh_config", + "printf", + "nginx", }, - config = function(_, opts) - local parser_config = require("nvim-treesitter.parsers").get_parser_configs() - parser_config.blade = { - install_info = { - url = "https://github.com/EmranMR/tree-sitter-blade", - branch = "main", - files = { "src/parser.c" }, - }, - filetype = "blade", - } + auto_install = true, - parser_config.dotenv = { - install_info = { - url = "https://github.com/pnx/tree-sitter-dotenv", - branch = "main", - files = { "src/parser.c", "src/scanner.c" }, - }, - filetype = "dotenv", - } - - vim.filetype.add({ - pattern = { - ['.env.*'] = 'dotenv', - }, - }) - - require("nvim-treesitter.configs").setup(opts) - end, - }, - { - "windwp/nvim-ts-autotag", - dependencies = { - "nvim-treesitter/nvim-treesitter", + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + + indent = { + enable = true, }, - event = "InsertEnter", - opts = {} }, + config = function(_, opts) + local parser_config = require("nvim-treesitter.parsers").get_parser_configs() + + parser_config.blade = { + install_info = { + url = "https://github.com/EmranMR/tree-sitter-blade", + branch = "main", + files = { "src/parser.c" }, + }, + filetype = "blade", + } + + parser_config.dotenv = { + install_info = { + url = "https://github.com/pnx/tree-sitter-dotenv", + branch = "main", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "dotenv", + } + + vim.filetype.add({ + pattern = { + ['.env.*'] = 'dotenv', + }, + }) + + require("nvim-treesitter.configs").setup(opts) + end, } diff --git a/nvim/lua/user/plugins/ide.lua b/nvim/lua/user/plugins/ide.lua index ac09a5b..935cc69 100644 --- a/nvim/lua/user/plugins/ide.lua +++ b/nvim/lua/user/plugins/ide.lua @@ -1,6 +1,8 @@ -local icons = require('user.icons') return { + { import = "user.plugins.ide.lsp" }, + { import = "user.plugins.ide.autocomplete" }, + { import = "user.plugins.ide.formatting" }, -- Linting { 'mfussenegger/nvim-lint', @@ -17,47 +19,23 @@ return { }) end, }, - -- Testing integration + -- Snippets { - "nvim-neotest/neotest", + "L3MON4D3/LuaSnip", + lazy = true, + build = "make install_jsregexp", dependencies = { - "nvim-neotest/nvim-nio", - "nvim-lua/plenary.nvim", - "antoinemadec/FixCursorHold.nvim", - "nvim-treesitter/nvim-treesitter" - }, - opts = { - floating = { - border = "none", - }, - output = { - enabled = true, - open_on_run = true, - }, - icons = { - child_indent = icons.tree.vertical, - child_prefix = icons.tree.node, - collapsed = icons.tree.horizontal, - non_collapsible = icons.tree.horizontal, - expanded = icons.tree.expanded, - final_child_indent = " ", - final_child_prefix = icons.tree.nodelast, - running_animated = { "⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓" }, - passed = icons.test.ok, - failed = icons.test.failed, - running = icons.test.running, - skipped = icons.test.skipped, - unknown = icons.test.unknown, - watching = icons.test.watch, + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, }, }, + opts = {}, config = function(_, opts) - local adapters = {} - for name, adapter_opts in pairs(opts.adapters or {}) do - table.insert(adapters, require(name)(adapter_opts)) - end - opts.adapters = adapters - require('neotest').setup(opts) - end - } + require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" }) + require("luasnip").setup(opts) + end, + }, } diff --git a/nvim/lua/user/plugins/ide/autocomplete.lua b/nvim/lua/user/plugins/ide/autocomplete.lua new file mode 100644 index 0000000..8696956 --- /dev/null +++ b/nvim/lua/user/plugins/ide/autocomplete.lua @@ -0,0 +1,66 @@ +local icons = require('user.icons') + +return { + 'saghen/blink.cmp', + lazy = false, + version = "*", + build = 'cargo build --release', + dependencies = { + { "xzbdmw/colorful-menu.nvim" }, + { 'L3MON4D3/LuaSnip', version = 'v2.*' }, + }, + opts = { + keymap = { + preset = "super-tab" + }, + appearance = { + nerd_font_variant = 'mono', + kind_icons = icons.symbols + }, + completion = { + list = { + selection = { + preselect = function(ctx) return ctx.mode ~= 'cmdline' end, + -- auto_insert = function(ctx) return ctx.mode ~= 'cmdline' end + auto_insert = false + } + }, + menu = { + min_width = 18, + winblend = 10, + draw = { + columns = { + { "kind_icon" }, + { "label", "source_name", gap = 1 }, + }, + components = { + label = { + text = function(ctx) + return require("colorful-menu").blink_components_text(ctx) + end, + highlight = function(ctx) + return require("colorful-menu").blink_components_highlight(ctx) + end, + }, + }, + }, + }, + documentation = { + auto_show = true, + window = { + winblend = 10 + } + }, + ghost_text = { + enabled = true, + } + }, + signature = { + enabled = true, + window = { + scrollbar = false, + winblend = 10, + } + } + } +} diff --git a/nvim/lua/user/plugins/ide/formatting.lua b/nvim/lua/user/plugins/ide/formatting.lua new file mode 100644 index 0000000..8fc462b --- /dev/null +++ b/nvim/lua/user/plugins/ide/formatting.lua @@ -0,0 +1,22 @@ +return { + 'stevearc/conform.nvim', + opts = { + default_format_opts = { + lsp_format = "fallback" + } + }, + init = function() + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" + user.formatter = function(args) + local range = nil + if args.count ~= -1 then + local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + range = { + start = { args.line1, 0 }, + ["end"] = { args.line2, end_line:len() }, + } + end + require("conform").format({ async = true, range = range }) + end + end +} diff --git a/nvim/lua/user/plugins/lsp.lua b/nvim/lua/user/plugins/ide/lsp.lua similarity index 100% rename from nvim/lua/user/plugins/lsp.lua rename to nvim/lua/user/plugins/ide/lsp.lua diff --git a/nvim/lua/user/plugins/ide/test.lua b/nvim/lua/user/plugins/ide/test.lua new file mode 100644 index 0000000..7441c3c --- /dev/null +++ b/nvim/lua/user/plugins/ide/test.lua @@ -0,0 +1,45 @@ +local icons = require('user.icons') + +return { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter" + }, + opts = { + floating = { + border = "none", + }, + output = { + enabled = true, + open_on_run = true, + }, + icons = { + child_indent = icons.tree.vertical, + child_prefix = icons.tree.node, + collapsed = icons.tree.horizontal, + non_collapsible = icons.tree.horizontal, + expanded = icons.tree.expanded, + final_child_indent = " ", + final_child_prefix = icons.tree.nodelast, + running_animated = { "⠋", "⠙", "⠚", "⠞", "⠖", "⠦", "⠴", "⠲", "⠳", "⠓" }, + passed = icons.test.ok, + failed = icons.test.failed, + running = icons.test.running, + skipped = icons.test.skipped, + unknown = icons.test.unknown, + watching = icons.test.watch, + }, + }, + config = function(_, opts) + local adapters = {} + for name, adapter_opts in pairs(opts.adapters or {}) do + table.insert(adapters, require(name)(adapter_opts)) + end + opts.adapters = adapters + require('neotest').setup(opts) + end +} + diff --git a/nvim/lua/user/plugins/tools.lua b/nvim/lua/user/plugins/tools.lua new file mode 100644 index 0000000..2e10469 --- /dev/null +++ b/nvim/lua/user/plugins/tools.lua @@ -0,0 +1,13 @@ +return { + { import = "user.plugins.tools.finder" }, + { + "williamboman/mason.nvim", + build = ":MasonUpdate", + cmd = "Mason", + opts_extend = { "ensure_installed" }, + opts = {}, + config = function(_, opts) + require("mason").setup(opts) + end + }, +} diff --git a/nvim/lua/user/plugins/editor/finder.lua b/nvim/lua/user/plugins/tools/finder.lua similarity index 100% rename from nvim/lua/user/plugins/editor/finder.lua rename to nvim/lua/user/plugins/tools/finder.lua diff --git a/nvim/lua/user/plugins/ui.lua b/nvim/lua/user/plugins/ui.lua index a17432d..27c928b 100644 --- a/nvim/lua/user/plugins/ui.lua +++ b/nvim/lua/user/plugins/ui.lua @@ -1,6 +1,45 @@ local ui = require("user.ui.telescope") +local icons = require('user.icons') return { + { import = "user.plugins.ui.dashboard" }, + + { import = "user.plugins.ui.editor" }, + + { import = "user.plugins.ui.colorscheme" }, + { import = "user.plugins.ui.statusline" }, + { import = "user.plugins.ui.statuscolumn" }, + { import = "user.plugins.ui.gitsigns" }, + -- File explorer + { import = "user.plugins.ui.neotree" }, + + { "folke/which-key.nvim", event = "VeryLazy" }, + + -- Icons + { + 'nvim-tree/nvim-web-devicons', + opts = { + override = { + php = { + icon = icons.filetypes.php, + color = "#4F5B93", + name = "Php" + } + }, + override_by_filename = { + ["artisan"] = { + icon = icons.filetypes.laravel, + color = "#f05340", + name = "LaravelArtisan" + }, + ["phpunit.xml"] = { + icon = icons.filetypes.phpunit, + color = "#0d6efd", + name = "PhpUnit" + } + } + } + }, { 'stevearc/dressing.nvim', opts = { @@ -27,9 +66,6 @@ return { } }, }, - { import = "user.plugins.ui.statusline" }, - -- File explorer - { import = "user.plugins.ui.neotree" }, -- Nicer notifications { "j-hui/fidget.nvim", @@ -48,8 +84,4 @@ return { } } }, - { - "folke/which-key.nvim", - event = "VeryLazy", - } } diff --git a/nvim/lua/user/plugins/ui/colorscheme.lua b/nvim/lua/user/plugins/ui/colorscheme.lua new file mode 100644 index 0000000..db59434 --- /dev/null +++ b/nvim/lua/user/plugins/ui/colorscheme.lua @@ -0,0 +1,258 @@ + +local custom_highlights = function(colors) + return { + CursorLine = { bg = colors.surface0 }, + SignColumnSep = { bg = colors.surface0, fg = colors.lavender }, + + Visual = { bg = colors.surface1 }, + FoldColumn = { fg = colors.surface2 }, + + -- Floating windows + NormalFloat = { fg = colors.text, bg = colors.crust }, + FloatTitle = { fg = colors.base, bg = colors.blue }, + FloatBorder = { fg = colors.surface1, bg = colors.crust }, + + -- Window separator + WinSeparator = { fg = colors.surface0 }, + + -- Menus + Pmenu = { link = "NormalFloat" }, + PmenuSel = { bg = colors.surface2 }, + PmenuSbar = { link = "Pmenu" }, + PmenuThumb = { link = "PmenuSel" }, + + -- NoiceMini = { link = "NormalFloat" }, + WhichKeyFloat = { link = "Pmenu" }, + + -- indent lines + IblScope = { fg = colors.surface0 }, + + -- Search matches + IncSearch = { bg = colors.yellow }, + + -- Autocomplete window + CmpItemAbbr = { fg = colors.overlay2 }, + CmpItemKindText = { fg = colors.text }, + + -- CmpKind + CmpItemKindBladeNav = { fg = "#f55247" }, + + -- telescope + TelescopeNormal = { link = "NormalFloat" }, + TelescopeBorder = { link = "FloatBorder" }, + TelescopeTitle = { link = "FloatTitle" }, + TelescopePromptNormal = { bg = colors.mantle }, + TelescopePromptPrefix = { fg = colors.mauve }, + TelescopePromptBorder = { fg = colors.mantle, bg = colors.mantle }, + TelescopePreviewTitle = { fg = colors.crust, bg = colors.mauve }, + TelescopeResultsNormal = { fg = colors.text, bg = colors.crust }, + TelescopeResultsClass = { link = "CmpItemKindClass" }, + TelescopeResultsInterface = { link = "CmpItemKindInterface" }, + TelescopeResultsField = { link = "CmpItemKindField" }, + TelescopeResultsFunction = { link = "CmpItemKindFunction" }, + TelescopeResultsMethod = { link = "CmpItemKindMethod" }, + TelescopeResultsNumber = { link = "CmpItemKindNumber" }, + TelescopeResultsStruct = { link = "CmpItemKindStruct" }, + TelescopeResultsConstant = { link = "CmpItemKindConstant" }, + TelescopeResultsOperator = { link = "CmpItemKindOperator" }, + TelescopeResultsVariable = { link = "CmpItemKindVariable" }, + TelescopeResultsIdentifier = { link = "CmpItemKindIdentifier" }, + TelescopeMatching = { fg = colors.lavender }, + TelescopeSelection = { fg = colors.text, bg = colors.surface1 }, + TelescopeIndicatorModified = { fg = colors.yellow }, + TelescopeIndicatorReadonly = { fg = colors.red }, + TelescopeIndicatorHidden = { link = "TelescopeResultsComment" }, + + -- Ufo + UfoFoldedEllipsis = { link = "Comment" }, + + -- Statusline + + -- Something resets StatusLine highlight background, so use another one for now :) + -- StatusLine = { fg = colors.text, bg = colors.crust }, + StatusLineLualine = { fg = colors.text, bg = colors.crust }, + + StatusLineNormal = { link = "StatusLineLualine" }, + StatusLineSeparator = { fg = colors.rosewater, bg = colors.crust }, + StatusLineInsert = { fg = colors.base, bg = colors.blue }, + StatusLineVisual = { fg = colors.base, bg = colors.mauve }, + StatusLineCommand = { fg = colors.base, bg = colors.yellow }, + StatusLineReplace = { fg = colors.base, bg = colors.maroon }, + + -- Neotree + NeoTreeTabActive = { bg = colors.surface2, fg = colors.lavender }, + NeoTreeTabInactive = { bg = colors.crust, fg = colors.surface2 }, + NeoTreeTabSeparatorActive = { fg = colors.base, bg = colors.surface2 }, + NeoTreeTabSeparatorInactive = { fg = colors.base, bg = colors.crust }, + NeoTreeFileIcon = { link = "Normal" }, + NeoTreeModified = { fg = colors.yellow }, + NeoTreeWinSeparator = { link = "WinSeparator" }, + + -- BlinkCmp + BlinkCmpLabel = { link = 'CmpItemAbbr' }, + BlinkCmpLabelMatch = { link = 'CmpItemAbbrMatch' }, + BlinkCmpLabelDeprecated = { link = 'CmpItemAbbrDeprecated'}, + BlinkCmpLabelDetail = { link = 'CmpItemMenu' }, + BlinkCmpLabelDescription = { link = 'CmpItemMenu' }, + + BlinkCmpSource = { link = 'CmpItemMenu' }, + BlinkCmpKind = { link = 'CmpItemKind' }, + BlinkCmpKindText = { link = "CmpItemKindText" }, + BlinkCmpKindMethod = { link = "CmpItemKindMethod" }, + BlinkCmpKindFunction = { link = "CmpItemKindFunction" }, + BlinkCmpKindConstructor = { link = "CmpItemKindConstructor" }, + BlinkCmpKindField = { link = "CmpItemKindField" }, + BlinkCmpKindVariable = { link = "CmpItemKindVariable" }, + BlinkCmpKindClass = { link = "CmpItemKindClass" }, + BlinkCmpKindInterface = { link = "CmpItemKindInterface" }, + BlinkCmpKindModule = { link = "CmpItemKindModule" }, + BlinkCmpKindProperty = { link = "CmpItemKindProperty" }, + BlinkCmpKindUnit = { link = "CmpItemKindUnit" }, + BlinkCmpKindValue = { link = "CmpItemKindValue" }, + BlinkCmpKindEnum = { link = "CmpItemKindEnum" }, + BlinkCmpKindKeyword = { link = "CmpItemKindKeyword" }, + BlinkCmpKindSnippet = { link = "CmpItemKindSnippet" }, + BlinkCmpKindColor = { link = "CmpItemKindColor" }, + BlinkCmpKindFile = { link = "CmpItemKindFile" }, + BlinkCmpKindReference = { link = "CmpItemKindReference" }, + BlinkCmpKindFolder = { link = "CmpItemKindFolder" }, + BlinkCmpKindEnumMember = { link = "CmpItemKindEnumMember" }, + BlinkCmpKindConstant = { link = "CmpItemKindConstant" }, + BlinkCmpKindStruct = { link = "CmpItemKindStruct" }, + BlinkCmpKindEvent = { link = "CmpItemKindEvent" }, + BlinkCmpKindOperator = { link = "CmpItemKindOperator" }, + BlinkCmpKindTypeParameter = { link = "CmpItemKindTypeParameter" }, + + -- Neotest + NeoTestWinSelect = { fg = colors.mauve }, + NeoTestIndent = { fg = colors.surface1 }, + NeoTestExpandMarker = { link = "NeoTestIndent" }, + NeoTestAdapterName = { fg = colors.mauve }, + NeoTestFile = { fg = colors.lavender }, + NeoTestDir = { fg = colors.blue }, + NeoTestTarget = { fg = colors.blue }, + NeoTestNamespace = { fg = colors.mauve }, + NeoTestPassed = { fg = colors.green }, + NeoTestFailed = { fg = colors.red }, + NeoTestSkipped = { fg = colors.blue }, + NeoTestRunning = { fg = colors.yellow }, + NeoTestWatching = { fg = colors.yellow }, + NeoTestMarked = { fg = colors.orange }, + + -- Diagnostics + DiagnosticUnderlineInfo = { style = {"undercurl"} }, + DiagnosticUnderlineHint = { style = {"undercurl"} }, + DiagnosticUnderlineWarn = { style = {"undercurl"} }, + DiagnosticUnderlineError = { style = {"undercurl"} }, + + -- Markdown rendering + RenderMarkdownCode = { bg = colors.crust }, + RenderMarkdownCodeInline = { fg = colors.rosewater, bg = colors.crust }, + + -- Syntax + PreProc = { fg = colors.mauve }, + Operator = { fg = colors.flamingo }, + Function = { link = "@text" }, + Delimiter = { link = "Operator" }, + Keyword = { fg = colors.yellow }, + Include = { link = "Keyword" }, + Repeat = { link = "Keyword" }, + Conditional = { link = "Keyword" }, + Type = { fg = colors.blue }, + Label = { link = "String" }, + String = { fg = colors.lavender }, + Exception = { link = "Keyword" }, + + -- Treesitter tokens + ["@constructor"] = { link = "Function" }, + ["@variable"] = { fg = colors.green }, + ["@variable.builtin"] = { link = "@variable" }, + ["@variable.parameter"] = { link = "@parameter" }, + ["@variable.member"] = { link = "@variable" }, + ["@parameter"] = { link = "@variable" }, + ["@keyword.function"] = { link = "Keyword" }, + ["@keyword.return"] = { link = "Keyword" }, + ["@keyword.operator"] = { link = "Keyword" }, + ["@property"] = { link = "@variable" }, + ["@tag"] = { link = "Keyword" }, + ["@tag.delimiter"] = { link = "@text" }, + ["@module"] = { link = "@text" }, + ["@namespace"] = { link = "@keyword" }, + ["@punctuation.bracket"] = { link = "@punctuation" }, + + -- LSP + ["@lsp.type.property"] = { link = "@variable" }, + ["@lsp.type.namespace.go"] = { fg = colors.rosewater }, + + -- Bash + ["@variable.parameter.bash"] = { fg = colors.rosewater }, + + -- Makefile + ["@function.make"] = { link = "Keyword" }, + ["@string.special.symbol.make"] = { link = "@variable" }, + + -- Markup + ["@markup.raw"] = { link = "@text" }, + ["@markup.strong"] = { fg = colors.blue }, + ["@markup.italic"] = { fg = colors.green }, + + -- PHP + ["@keyword.import.php"] = { link = "@keyword" }, + ["@function.builtin.php"] = { fg = colors.blue }, + ["@class.name.php"] = { link = "@text" }, + ["@class.inherit.name.php"] = { link = "@text" }, + ["@class.implements.name.php"] = { link = "@text" }, + ["@interface.name.php"] = { link = "@text" }, + ["@namespace.name.php"] = { link = "@text" }, + ["@namespace.alias.name.php"] = { link = "@text" }, + ["@use.trait.name.php"] = { link = "@text" }, + + -- Blade + ["@tag.blade"] = { fg = colors.mauve }, + } +end + +local options = { + flavour = "mocha", + transparent_background = not vim.g.neovide, + color_overrides = { + mocha = { + base = "#0E1019", + mantle = "#0D0F17", + crust = "#0C0D14", + surface0 = "#1a1c2d", + surface1 = "#343959", + surface2 = "#41476F", + overlay0 = "#3F4256", + overlay1 = "#5B5F7C", + overlay2 = "#767BA0", + + text = "#eceef4", + }, + }, + no_italic = true, + no_bold = true, + custom_highlights = custom_highlights, + integrations = { + cmp = true, + treesitter = true, + neotree = true, + -- barbar = true, + -- noice = true, + telescope = { + enabled = true, + }, + } +} + +return { + "catppuccin/nvim", + name = "catppuccin", + lazy = false, + priority = 1000, + opts = options, + config = function(_, opts) + require("catppuccin").setup(opts) + vim.cmd.colorscheme("catppuccin") + end, +} diff --git a/nvim/lua/user/plugins/ui/dashboard.lua b/nvim/lua/user/plugins/ui/dashboard.lua new file mode 100644 index 0000000..74af816 --- /dev/null +++ b/nvim/lua/user/plugins/ui/dashboard.lua @@ -0,0 +1,27 @@ +local icons = require('user.icons') + +return { + "goolord/alpha-nvim", + config = function() + local alpha = require'alpha' + local dashboard = require'alpha.themes.dashboard' + + dashboard.section.header.val = { + [[ __ ]], + [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], + [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], + [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], + } + + dashboard.section.buttons.val = { + dashboard.button("e", icons.files.text .. " New file" , ":ene startinsert"), + dashboard.button("s", icons.search .. " Search files" , ":Telescope find_files"), + dashboard.button("o", icons.search .. " Old files" , ":Telescope oldfiles"), + dashboard.button("q", icons.close .. " Quit" , ":qa"), + } + + alpha.setup(dashboard.config) + end +} diff --git a/nvim/lua/user/plugins/ui/editor.lua b/nvim/lua/user/plugins/ui/editor.lua new file mode 100644 index 0000000..6d01b50 --- /dev/null +++ b/nvim/lua/user/plugins/ui/editor.lua @@ -0,0 +1,54 @@ +local icons = require('user.icons') + +return { + -- indent lines + { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + opts = { + debounce = 10, + indent = { + char = icons.indent, + }, + scope = { + enabled = false, + }, + exclude = { + filetypes = { + "help", + "dashboard", + }, + }, + }, + config = function(_, opts) + require("ibl").setup(opts) + + local hooks = require("ibl.hooks") + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_tab_indent_level) + hooks.register(hooks.type.WHITESPACE, hooks.builtin.hide_first_space_indent_level) + end, + }, + { + "folke/todo-comments.nvim", + dependencies = { "nvim-lua/plenary.nvim" }, + opts = { + signs = false, + keywords = { + TODO = { color = "warning" }, + }, + highlight = { + keyword = 'fg', + } + } + }, + -- color highlight in documents + { + 'brenoprata10/nvim-highlight-colors', + opts = { + render = 'virtual', + virtual_symbol_position = 'eol', + virtual_symbol_prefix = '', + virtual_symbol_suffix = '', + } + }, +} diff --git a/nvim/lua/user/plugins/ui/gitsigns.lua b/nvim/lua/user/plugins/ui/gitsigns.lua new file mode 100644 index 0000000..56bfe05 --- /dev/null +++ b/nvim/lua/user/plugins/ui/gitsigns.lua @@ -0,0 +1,42 @@ +local icons = require('user.icons').diff_gutter + +local options = { + signs = { + add = { text = icons.add }, + delete = { text = icons.delete }, + change = { text = icons.change }, + untracked = { text = icons.untracked }, + topdelete = { text = icons.delete }, + changedelete = { text = icons.change }, + }, + signs_staged = { + add = { text = icons.add }, + delete = { text = icons.delete }, + change = { text = icons.change }, + topdelete = { text = icons.delete }, + changedelete = { text = icons.change }, + }, + diff_opts = { + internal = true + }, + preview_config = { + border = { " " }, + } +} + +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["g"] = { name = "+git" }, + }, + }, + }, + }, + opts = options, +} diff --git a/nvim/lua/user/plugins/ui/neotree.lua b/nvim/lua/user/plugins/ui/neotree.lua index 52a71fc..c8f79ce 100644 --- a/nvim/lua/user/plugins/ui/neotree.lua +++ b/nvim/lua/user/plugins/ui/neotree.lua @@ -1,5 +1,107 @@ local icons = require("user.icons") +local options = { + -- weird bug + -- hide_root_node = true, + popup_border_style = 'solid', + default_component_configs = { + indent = { + with_markers = true, + indent_marker = icons.tree.vertical, + last_indent_marker = icons.tree.nodelast, + indent_size = 2, + }, + icon = { + folder_closed = icons.folder.closed, + folder_open = icons.folder.open, + folder_empty = icons.folder.empty, + folder_empty_open = icons.folder.empty_open, + default = icons.files.default, + }, + modified = { + symbol = icons.modified, + }, + name = { + highlight_opened_files = true, + }, + git_status = { + symbols = icons.gitsigns, + align = "right", + }, + }, + sources = { + "filesystem", + -- "buffers", + -- "git_status", + -- "document_symbols", + }, + source_selector = { + winbar = true, -- toggle to show selector on winbar + show_scrolled_off_parent_node = false, -- boolean + sources = { -- table + { + source = "filesystem", + display_name = " 󰉓 Files " + }, + { + source = "buffers", + display_name = "  Buffers " + }, + { + source = "git_status", + display_name = " 󰊢 Git " + }, + { + source = "document_symbols", + display_name = "  Document Symbols " + }, + }, + content_layout = "center", + separator = { left = "", right= "" }, + }, + window = { + popup = { + size = { + height = "100%", + width = "100%", + }, + position = "50%", + relative = "editor", + }, + mappings = { + [""] = "noop", + } + }, + filesystem = { + follow_current_file = { + enabled = true, + }, + use_libuv_file_watcher = true, + window = { + mappings = { + ["."] = "noop", -- unbind set_root. I never use it but always hit the key :P + ["~"] = "toggle_hidden", + } + }, + }, + buffers = { + window = { + mappings = { + ["."] = "noop", + } + } + }, + event_handlers = { + { + event = "neo_tree_buffer_enter", + handler = function () + vim.opt_local.statuscolumn = '' + vim.opt_local.foldcolumn = "0" + end + }, + }, +} + return { "nvim-neo-tree/neo-tree.nvim", branch = "v3.x", @@ -9,106 +111,6 @@ return { "MunifTanjim/nui.nvim", }, cmd = "Neotree", - opts = { - -- weird bug - -- hide_root_node = true, - popup_border_style = 'solid', - default_component_configs = { - indent = { - with_markers = true, - indent_marker = icons.tree.vertical, - last_indent_marker = icons.tree.nodelast, - indent_size = 2, - }, - icon = { - folder_closed = icons.folder.closed, - folder_open = icons.folder.open, - folder_empty = icons.folder.empty, - folder_empty_open = icons.folder.empty_open, - default = icons.files.default, - }, - modified = { - symbol = icons.modified, - }, - name = { - highlight_opened_files = true, - }, - git_status = { - symbols = icons.gitsigns, - align = "right", - }, - }, - sources = { - "filesystem", - "buffers", - "git_status", - "document_symbols", - }, - source_selector = { - winbar = true, -- toggle to show selector on winbar - show_scrolled_off_parent_node = false, -- boolean - sources = { -- table - { - source = "filesystem", - display_name = " 󰉓 Files " - }, - { - source = "buffers", - display_name = "  Buffers " - }, - { - source = "git_status", - display_name = " 󰊢 Git " - }, - { - source = "document_symbols", - display_name = "  Document Symbols " - }, - }, - content_layout = "center", - separator = { left = "", right= "" }, - }, - window = { - popup = { - size = { - height = "100%", - width = "100%", - }, - position = "50%", - relative = "editor", - }, - mappings = { - [""] = "noop", - } - }, - filesystem = { - follow_current_file = { - enabled = true, - }, - use_libuv_file_watcher = true, - window = { - mappings = { - ["."] = "noop", -- unbind set_root. I never use it but always hit the key :P - ["~"] = "toggle_hidden", - } - }, - }, - buffers = { - window = { - mappings = { - ["."] = "noop", - } - } - }, - event_handlers = { - { - event = "neo_tree_buffer_enter", - handler = function () - vim.opt_local.statuscolumn = '' - vim.opt_local.foldcolumn = "0" - end - }, - }, - }, + opts = options } diff --git a/nvim/lua/user/plugins/ui/statuscolumn.lua b/nvim/lua/user/plugins/ui/statuscolumn.lua new file mode 100644 index 0000000..e9d20bf --- /dev/null +++ b/nvim/lua/user/plugins/ui/statuscolumn.lua @@ -0,0 +1,58 @@ +local icons = require('user.icons') + +local opts = function() + local builtin = require("statuscol.builtin") + return { + -- Align current relative number to the right. + relculright = true, + ft_ignore = { + 'help', + 'alpha' + }, + segments = { + { + click = "v:lua.ScSa", + sign = { + namespace = { "gitsigns" }, + maxwidth = 1, + colwidth = 1, + foldclosed = true, + } + }, + { + click = "v:lua.ScSa", + sign = { + name = { ".*" }, + namespace = { ".*" }, + maxwidth = 1, + foldclosed = true, + }, + }, + { + text = { " ", builtin.lnumfunc, " " }, + click = "v:lua.ScLa", + }, + { + text = { builtin.foldfunc, " " }, + condition = { true, function (args) return args.fold.width > 0 end }, + click = "v:lua.ScFa" + }, + { + text = { + function(args) + local pos = vim.api.nvim_win_get_cursor(args.win) + return (args.lnum == pos[1] and "%#SignColumnSep#" or "")..icons.signcolum.separator + end, + }, + }, + } + } +end + +-- Better status column +return { + "luukvbaal/statuscol.nvim", + event = { "BufReadPre", "BufNewFile", "BufAdd" }, + opts = opts +} + diff --git a/nvim/lua/user/plugins/ui/statusline.lua b/nvim/lua/user/plugins/ui/statusline.lua index e8af085..3333982 100644 --- a/nvim/lua/user/plugins/ui/statusline.lua +++ b/nvim/lua/user/plugins/ui/statusline.lua @@ -1,5 +1,9 @@ local icons = require("user.icons") +-- +-- Helper functions +-- + local function indent_settings() return (vim.bo.expandtab and "SPC" or "TAB") .. ":" @@ -26,6 +30,141 @@ local function linter() return "no linter" end +-- +-- Options +-- + +local options = { + options = { + globalstatus = true, + component_separators = "", + section_separators = "", + disabled_filetypes = { + statusline = { + "dashboard", + "alpha", + }, + winbar = { + "neo-tree", + "NvimTree", + "alpha" + } + }, + theme = { + normal = { + a = "StatusLineNormal", + b = "StatusLineLualine", + c = "StatusLineLualine", + x = "StatusLineLualine", + y = "StatusLineLualine", + z = "StatusLineLualine", + }, + command = { + a = "StatusLineCommand", + }, + insert = { + a = "StatusLineInsert", + }, + visual = { + a = "StatusLineVisual", + }, + replace = { + a = "StatusLineReplace", + }, + }, + }, + sections = { + lualine_a = { + "mode", + }, + lualine_b = { + {"branch"}, + { + "diagnostics", + symbols = { + error = icons.diagnostics.error .. " ", + warn = icons.diagnostics.warn .. " ", + info = icons.diagnostics.info .. " ", + hint = icons.diagnostics.hint .. " ", + }, + }, + { + "diff", + symbols = { + added = icons.diff.added .. " ", + modified = icons.diff.modified .. " ", + removed = icons.diff.removed .. " ", + }, + }, + { + "lsp-status", + disabled_filetypes = { + "TelescopePrompt", + }, + on_click = function (_, btn, _) + if btn == "l" then + vim.cmd(":LspInfo") + elseif btn == "r" then + vim.cmd(":LspRestart") + end + end + }, + linter, + }, + lualine_c = {}, + lualine_x = { + { + "filetype", + cond = is_not_popup + }, + { + "fileformat", + symbols = { + unix = "NL", + dos = "NLCR", + mac = 'NL' + } + }, + indent_settings, + }, + lualine_y = { + "location", + "progress", + }, + lualine_z = {}, + }, + winbar = { + lualine_c = { + { "filetype", icon_only = true }, + { + "filename", + cond = is_not_popup, + path = 1, + symbols = vim.tbl_deep_extend("force", icons.file_status, { + unnamed = "", + }) + }, + }, + }, + inactive_winbar = { + lualine_c = { + { "filetype", icon_only = true }, + { + "filename", + cond = is_not_popup, + path = 1, + symbols = vim.tbl_deep_extend("force", icons.file_status, { + unnamed = "", + }) + }, + }, + }, + extensions = { + "lazy", + "neo-tree", + }, +} + return { "nvim-lualine/lualine.nvim", event = "VeryLazy", @@ -33,136 +172,7 @@ return { "nvim-tree/nvim-web-devicons", "pnx/lualine-lsp-status", }, - opts = { - options = { - globalstatus = true, - component_separators = "", - section_separators = "", - disabled_filetypes = { - statusline = { - "dashboard", - "alpha", - }, - winbar = { - "neo-tree", - "NvimTree", - "alpha" - } - }, - theme = { - normal = { - a = "StatusLineNormal", - b = "StatusLineLualine", - c = "StatusLineLualine", - x = "StatusLineLualine", - y = "StatusLineLualine", - z = "StatusLineLualine", - }, - command = { - a = "StatusLineCommand", - }, - insert = { - a = "StatusLineInsert", - }, - visual = { - a = "StatusLineVisual", - }, - replace = { - a = "StatusLineReplace", - }, - }, - }, - sections = { - lualine_a = { - "mode", - }, - lualine_b = { - {"branch"}, - { - "diagnostics", - symbols = { - error = icons.diagnostics.error .. " ", - warn = icons.diagnostics.warn .. " ", - info = icons.diagnostics.info .. " ", - hint = icons.diagnostics.hint .. " ", - }, - }, - { - "diff", - symbols = { - added = icons.diff.added .. " ", - modified = icons.diff.modified .. " ", - removed = icons.diff.removed .. " ", - }, - }, - { - "lsp-status", - disabled_filetypes = { - "TelescopePrompt", - }, - on_click = function (_, btn, _) - if btn == "l" then - vim.cmd(":LspInfo") - elseif btn == "r" then - vim.cmd(":LspRestart") - end - end - }, - linter, - }, - lualine_c = {}, - lualine_x = { - { - "filetype", - cond = is_not_popup - }, - { - "fileformat", - symbols = { - unix = "NL", - dos = "NLCR", - mac = 'NL' - } - }, - indent_settings, - }, - lualine_y = { - "location", - "progress", - }, - lualine_z = {}, - }, - winbar = { - lualine_c = { - { "filetype", icon_only = true }, - { - "filename", - cond = is_not_popup, - path = 1, - symbols = vim.tbl_deep_extend("force", icons.file_status, { - unnamed = "", - }) - }, - }, - }, - inactive_winbar = { - lualine_c = { - { "filetype", icon_only = true }, - { - "filename", - cond = is_not_popup, - path = 1, - symbols = vim.tbl_deep_extend("force", icons.file_status, { - unnamed = "", - }) - }, - }, - }, - extensions = { - "lazy", - "neo-tree", - }, - }, + opts = options, init = function () -- disable mode in the command line, as its already shown in lualine vim.o.showmode = false