From 04a2178f3a729e7a323419962989bea06d6d3de0 Mon Sep 17 00:00:00 2001 From: Dave Damage Date: Tue, 4 Nov 2025 11:44:29 +0100 Subject: [PATCH] Initial commit --- colors/sweet.lua | 219 ++++++++++++++++++++++++++ init.lua | 5 + lazy-lock.json | 29 ++++ lua/config/keymaps.lua | 100 ++++++++++++ lua/config/lazy.lua | 30 ++++ lua/config/options.lua | 28 ++++ lua/plugins/automkdir.lua | 4 + lua/plugins/autopairs.lua | 18 +++ lua/plugins/cheatsheet.lua | 15 ++ lua/plugins/comment.lua | 6 + lua/plugins/completion.lua | 40 +++++ lua/plugins/conform.lua | 42 +++++ lua/plugins/gitsigns.lua | 38 +++++ lua/plugins/indent-blankline.lua | 24 +++ lua/plugins/index.lua | 20 +++ lua/plugins/lsp.lua | 117 ++++++++++++++ lua/plugins/lualine.lua | 253 +++++++++++++++++++++++++++++++ lua/plugins/sleuth.lua | 4 + lua/plugins/surround.lua | 6 + lua/plugins/telescope.lua | 44 ++++++ lua/plugins/treesitter.lua | 37 +++++ lua/plugins/undotree.lua | 6 + lua/plugins/which-key.lua | 14 ++ 23 files changed, 1099 insertions(+) create mode 100644 colors/sweet.lua create mode 100755 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/config/keymaps.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/options.lua create mode 100644 lua/plugins/automkdir.lua create mode 100644 lua/plugins/autopairs.lua create mode 100644 lua/plugins/cheatsheet.lua create mode 100644 lua/plugins/comment.lua create mode 100644 lua/plugins/completion.lua create mode 100644 lua/plugins/conform.lua create mode 100644 lua/plugins/gitsigns.lua create mode 100644 lua/plugins/indent-blankline.lua create mode 100644 lua/plugins/index.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/sleuth.lua create mode 100644 lua/plugins/surround.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/undotree.lua create mode 100644 lua/plugins/which-key.lua diff --git a/colors/sweet.lua b/colors/sweet.lua new file mode 100644 index 0000000..a842615 --- /dev/null +++ b/colors/sweet.lua @@ -0,0 +1,219 @@ +-- ~/.config/nvim/colors/sweet.lua +-- Sweet colorscheme for Neovim +-- Based on the Sweet GTK theme colors + +-- Reset colors +vim.cmd("highlight clear") +if vim.fn.exists("syntax_on") then + vim.cmd("syntax reset") +end + +vim.o.termguicolors = true +vim.g.colors_name = "sweet" + +-- Sweet GTK Theme Colors (from actual source code) +local colors = { + -- Core colors + bg = "#161925", -- Sweet background + fg = "#C3C7D1", -- Sweet foreground + bg_dark = "#121520", -- Darker background + bg_light = "#1a1f2e", -- Lighter background + bg_sidebar = "#222e39", -- Panel background + + -- Sweet Primary Colors + lime = "#71f79f", -- Sweet lime + red = "#ed254e", -- Sweet red + orange = "#ff6a00", -- Sweet orange + yellow = "#f9dc5c", -- Sweet yellow + purple = "#c74ded", -- Sweet purple + dark_purple = "#7b7bbd", -- Sweet dark purple + blue = "#7cb7ff", -- Sweet blue + cyan = "#00c1e4", -- Sweet cyan + teal = "#00e8c6", -- Sweet teal + + -- Sweet UI Colors + selected_bg = "#00D3A7", -- Sweet selected background + selected_fg = "#fefefe", -- Sweet selected foreground + + -- Derived colors + comment = "#6c7086", -- Muted text + line_number = "#585b70", -- Line numbers + cursor_line = "#1e1e2e", -- Current line highlight + visual = "#313244", -- Visual selection + search = "#45475a", -- Search highlight + + -- Status colors + error = "#ed254e", -- Error (Sweet red) + warning = "#f9dc5c", -- Warning (Sweet yellow) + info = "#7cb7ff", -- Info (Sweet blue) + hint = "#00e8c6", -- Hint (Sweet teal) + success = "#71f79f", -- Success (Sweet lime) +} + +-- Helper function to set highlight groups +local function hl(group, opts) + vim.api.nvim_set_hl(0, group, opts) +end + +-- Editor highlights +hl("Normal", { fg = colors.fg, bg = colors.bg }) +hl("NormalFloat", { fg = colors.fg, bg = colors.bg_light }) +hl("CursorLine", { bg = colors.cursor_line }) +hl("CursorColumn", { bg = colors.cursor_line }) +hl("ColorColumn", { bg = colors.bg_light }) +hl("LineNr", { fg = colors.line_number }) +hl("CursorLineNr", { fg = colors.yellow, bold = true }) +hl("SignColumn", { fg = colors.line_number, bg = colors.bg }) +hl("Folded", { fg = colors.comment, bg = colors.bg_light }) +hl("FoldColumn", { fg = colors.comment, bg = colors.bg }) + +-- Search and selection +hl("Visual", { bg = colors.visual }) +hl("VisualNOS", { bg = colors.visual }) +hl("Search", { bg = colors.search, fg = colors.yellow }) +hl("IncSearch", { bg = colors.yellow, fg = colors.bg }) +hl("CurSearch", { bg = colors.orange, fg = colors.bg }) + +-- UI elements +hl("Pmenu", { fg = colors.fg, bg = colors.bg_light }) +hl("PmenuSel", { fg = colors.selected_fg, bg = colors.selected_bg }) +hl("PmenuSbar", { bg = colors.bg_sidebar }) +hl("PmenuThumb", { bg = colors.purple }) +hl("StatusLine", { fg = colors.fg, bg = colors.bg_sidebar }) +hl("StatusLineNC", { fg = colors.comment, bg = colors.bg_light }) +hl("TabLine", { fg = colors.comment, bg = colors.bg_light }) +hl("TabLineFill", { bg = colors.bg_light }) +hl("TabLineSel", { fg = colors.fg, bg = colors.bg }) +hl("WinSeparator", { fg = colors.bg_light }) +hl("VertSplit", { fg = colors.bg_light }) + +-- Syntax highlighting +hl("Comment", { fg = colors.comment, italic = true }) +hl("Constant", { fg = colors.orange }) +hl("String", { fg = colors.lime }) +hl("Character", { fg = colors.lime }) +hl("Number", { fg = colors.purple }) +hl("Boolean", { fg = colors.purple }) +hl("Float", { fg = colors.purple }) + +hl("Identifier", { fg = colors.cyan }) +hl("Function", { fg = colors.blue }) + +hl("Statement", { fg = colors.red }) +hl("Conditional", { fg = colors.red }) +hl("Repeat", { fg = colors.red }) +hl("Label", { fg = colors.red }) +hl("Operator", { fg = colors.teal }) +hl("Keyword", { fg = colors.red }) +hl("Exception", { fg = colors.red }) + +hl("PreProc", { fg = colors.yellow }) +hl("Include", { fg = colors.yellow }) +hl("Define", { fg = colors.yellow }) +hl("Macro", { fg = colors.yellow }) +hl("PreCondit", { fg = colors.yellow }) + +hl("Type", { fg = colors.teal }) +hl("StorageClass", { fg = colors.teal }) +hl("Structure", { fg = colors.teal }) +hl("Typedef", { fg = colors.teal }) + +hl("Special", { fg = colors.purple }) +hl("SpecialChar", { fg = colors.purple }) +hl("Tag", { fg = colors.cyan }) +hl("Delimiter", { fg = colors.fg }) +hl("SpecialComment", { fg = colors.comment, italic = true }) +hl("Debug", { fg = colors.red }) + +-- Diagnostics +hl("DiagnosticError", { fg = colors.error }) +hl("DiagnosticWarn", { fg = colors.warning }) +hl("DiagnosticInfo", { fg = colors.info }) +hl("DiagnosticHint", { fg = colors.hint }) +hl("DiagnosticUnderlineError", { undercurl = true, sp = colors.error }) +hl("DiagnosticUnderlineWarn", { undercurl = true, sp = colors.warning }) +hl("DiagnosticUnderlineInfo", { undercurl = true, sp = colors.info }) +hl("DiagnosticUnderlineHint", { undercurl = true, sp = colors.hint }) + +-- Git signs +hl("GitSignsAdd", { fg = colors.success }) +hl("GitSignsChange", { fg = colors.warning }) +hl("GitSignsDelete", { fg = colors.error }) + +-- Tree-sitter highlights +hl("@variable", { fg = colors.fg }) +hl("@variable.builtin", { fg = colors.purple }) +hl("@variable.parameter", { fg = colors.orange }) +hl("@variable.member", { fg = colors.cyan }) + +hl("@constant", { fg = colors.orange }) +hl("@constant.builtin", { fg = colors.purple }) +hl("@constant.macro", { fg = colors.yellow }) + +hl("@string", { fg = colors.lime }) +hl("@string.escape", { fg = colors.purple }) +hl("@string.special", { fg = colors.purple }) + +hl("@character", { fg = colors.lime }) +hl("@number", { fg = colors.purple }) +hl("@boolean", { fg = colors.purple }) +hl("@float", { fg = colors.purple }) + +hl("@function", { fg = colors.blue }) +hl("@function.builtin", { fg = colors.cyan }) +hl("@function.call", { fg = colors.blue }) +hl("@function.macro", { fg = colors.yellow }) + +hl("@method", { fg = colors.blue }) +hl("@method.call", { fg = colors.blue }) + +hl("@constructor", { fg = colors.teal }) +hl("@parameter", { fg = colors.orange }) + +hl("@keyword", { fg = colors.red }) +hl("@keyword.function", { fg = colors.red }) +hl("@keyword.operator", { fg = colors.red }) +hl("@keyword.return", { fg = colors.red }) +hl("@keyword.conditional", { fg = colors.red }) +hl("@keyword.repeat", { fg = colors.red }) +hl("@keyword.import", { fg = colors.yellow }) + +hl("@operator", { fg = colors.teal }) + +hl("@type", { fg = colors.teal }) +hl("@type.builtin", { fg = colors.purple }) +hl("@type.definition", { fg = colors.teal }) + +hl("@property", { fg = colors.cyan }) +hl("@field", { fg = colors.cyan }) + +hl("@tag", { fg = colors.red }) +hl("@tag.attribute", { fg = colors.orange }) +hl("@tag.delimiter", { fg = colors.fg }) + +hl("@comment", { fg = colors.comment, italic = true }) +hl("@comment.todo", { fg = colors.yellow, bold = true }) +hl("@comment.warning", { fg = colors.warning, bold = true }) +hl("@comment.note", { fg = colors.info, bold = true }) +hl("@comment.error", { fg = colors.error, bold = true }) + +-- Error and warning +hl("Error", { fg = colors.error }) +hl("ErrorMsg", { fg = colors.error }) +hl("WarningMsg", { fg = colors.warning }) +hl("Title", { fg = colors.purple, bold = true }) +hl("Directory", { fg = colors.blue }) +hl("MoreMsg", { fg = colors.lime }) +hl("Question", { fg = colors.cyan }) + +-- Diff +hl("DiffAdd", { bg = "#2a3a2d" }) +hl("DiffChange", { bg = "#3a3a2d" }) +hl("DiffDelete", { bg = "#3a2a2d" }) +hl("DiffText", { bg = "#4a4a3d" }) + +-- Spell +hl("SpellBad", { undercurl = true, sp = colors.error }) +hl("SpellCap", { undercurl = true, sp = colors.warning }) +hl("SpellLocal", { undercurl = true, sp = colors.info }) +hl("SpellRare", { undercurl = true, sp = colors.hint }) diff --git a/init.lua b/init.lua new file mode 100755 index 0000000..1c7dfa5 --- /dev/null +++ b/init.lua @@ -0,0 +1,5 @@ +require("config.options") +require("config.lazy") +require("config.keymaps") + +vim.cmd.colorscheme("sweet") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..9cd90cf --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,29 @@ +{ + "LuaSnip": { "branch": "master", "commit": "ccf25a5452b8697a823de3e5ecda63ed3d723b79" }, + "automkdir.nvim": { "branch": "main", "commit": "e36da288764cc41864dc5b4e1234f1425033ce59" }, + "cheatsheet.nvim": { "branch": "master", "commit": "9716f9aaa94dd1fd6ce59b5aae0e5f25e2a463ef" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, + "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "conform.nvim": { "branch": "master", "commit": "9fd3d5e0b689ec1bf400c53cbbec72c6fdf24081" }, + "gitsigns.nvim": { "branch": "main", "commit": "20ad4419564d6e22b189f6738116b38871082332" }, + "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "3590d66effccc7376d8c3dbe45e8291f9fed2843" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" }, + "nvim-cmp": { "branch": "main", "commit": "a7bcf1d88069fc67c9ace8a62ba480b8fe879025" }, + "nvim-lspconfig": { "branch": "master", "commit": "64e0a1c6ba39417ee81a893ebbb4f8e4a949445c" }, + "nvim-surround": { "branch": "main", "commit": "fcfa7e02323d57bfacc3a141f8a74498e1522064" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "undotree": { "branch": "master", "commit": "0f1c9816975b5d7f87d5003a19c53c6fd2ff6f7f" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } +} diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..e09c4a7 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,100 @@ +-- Universal Operations +-- n => new/create +-- q => quit/close +-- s => save/write +-- x => exit (save&quit) +-- d => delete/remove +-- r => rename/reload/refresh +-- o => open +-- a => add +-- A => all +-- e => edit +-- t => toggle +-- h/l => previous/next +-- j/k => last/first + +local map = vim.keymap.set +-- Leader Key Groups +map("n", "b", "", { desc = "+buffers" }) +map("n", "c", "", { desc = "+code" }) +map("n", "d", "", { desc = "+diagnostics" }) +map("n", "e", "", { desc = "+file actions" }) +map("n", "f", "", { desc = "+find" }) +map("n", "g", "", { desc = "+git" }) +map("n", "l", "", { desc = "+lazy" }) +map("n", "m", "", { desc = "+movement" }) +map("n", "s", "", { desc = "+search" }) +map("n", "t", "", { desc = "+tabs" }) +map("n", "u", "", { desc = "+ui" }) +map("n", "w", "", { desc = "+windows" }) +map("n", "x", "", { desc = "+quickfix" }) +-- MacOs Style +map({ "n", "i", "v", "s" }, "", "w", { desc = "Save File" }) +map("n", "", "u", { desc = "Undo" }) +map("n", "", "", { desc = "Redo" }) +map("n", "", "ggG", { desc = "Select all" }) +map("n", "", "j", { desc = "Clear search highlight" }) +-- Window +map("n", "wh", "h", { desc = "Go to left window" }) +map("n", "wj", "j", { desc = "Go to lower window" }) +map("n", "wk", "k", { desc = "Go to upper window" }) +map("n", "wl", "l", { desc = "Go to right window" }) +map("n", "w|", "v", { desc = "Split vertically" }) +map("n", "w-", "s", { desc = "Split horizontally" }) +map("n", "wq", "c", { desc = "Close window" }) +map("n", "wQ", "o", { desc = "Close other windows" }) +map("n", "w=", "=", { desc = "Equal width/height" }) +map("n", "ww", "w", { desc = "Switch windows" }) +map("n", "", "vertical resize -2", { desc = "Decrease width" }) +map("n", "", "vertical resize +2", { desc = "Increase width" }) +map("n", "", "resize -2", { desc = "Decrease height" }) +map("n", "", "resize +2", { desc = "Increase height" }) +-- Buffer +map("n", "bA", "buffers", { desc = "List buffers" }) +map("n", "bh", "bprevious", { desc = "Previous buffer" }) +map("n", "bl", "bnext", { desc = "Next buffer" }) +map("n", "bk", "bfirst", { desc = "First buffer" }) +map("n", "bj", "blast", { desc = "Last buffer" }) +map("n", "bd", "bdelete", { desc = "Delete buffer" }) +map("n", "bk", "bprevious", { desc = "Previous buffer" }) +-- Tabs +map("n", "tn", "tabnew", { desc = "New Tab" }) +map("n", "tq", "tabclose", { desc = "Close tab" }) +map("n", "tk", "tabfirst", { desc = "First tab" }) +map("n", "tj", "tabfirst", { desc = "Last tab" }) +map("n", "th", "tabprevious", { desc = "Previous tab" }) +map("n", "tl", "tabnext", { desc = "Next tab" }) +-- File Actions +map("n", "en", "enew", { desc = "New file" }) +map("n", "eq", "q", { desc = "Quit file" }) +map("n", "eQ", "qa!", { desc = "Quit all" }) +map("n", "ex", "wq", { desc = "Save + quit file" }) +-- Lazy +map("n", "ll", "Lazy", { desc = "Lazy Plugin Manager" }) +-- UI +map("n", "uw", "set wrap!", { desc = "Toggle word wrap" }) +map("n", "un", "set number!", { desc = "Toggle line numbers" }) +map("n", "ur", "set relativenumber!", { desc = "Toggle relative number" }) +-- Quickfixes +map("n", "xl", "cnext", { desc = "Next quickfix" }) +map("n", "xh", "cprev", { desc = "Previous quickfix" }) +map("n", "xo", "copen", { desc = "Open quickfix" }) +map("n", "xq", "cclose", { desc = "Close quickfix" }) +-- Movement +map("n", "j", "gj", { desc = "Move down (Wrapped Line)" }) +map("n", "k", "gk", { desc = "Move up (Wrapped Line)" }) +map("n", "mj", "m .+1==", { desc = "Move line down" }) +map("n", "mk", "m .-2==", { desc = "Move line up" }) +map("n", "mh", "{", { desc = "Previous paragraph" }) +map("n", "ml", "}", { desc = "Next paragraph" }) +map("v", "mj", ":m '>.+1gv=gv", { desc = "Move selection down" }) +map("v", "mk", ":m '<-2gv=gv", { desc = "Move selection up" }) +-- Identing +map("v", "<", "", ">gv", { desc = "Indent right" }) +map("v", "", ">gv", { desc = "Indent right" }) +map("v", "", "?", "Cheatsheet", { desc = "Show cheatsheet" }) +-- Search for selection +map("v", "//", 'y/\\V=escape(@",\'/\\\')', { desc = "Search selection" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..0211eac --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,30 @@ +local lazypath = vim.fn.stdpath("data") .. "lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + lazyrepo, + lazypath + }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim \n", "ErrorMsg" }, + { out, "WarningsMsg" }, + { "\nPress any key to exit" }, + }, true, {}) + vim.gn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) +vim.g.mapleader = " " +vim.g.maplocalleader = "," +require("lazy").setup({ + spec = { + import = "plugins" + }, + checker = { enabled = true } +}) diff --git a/lua/config/options.lua b/lua/config/options.lua new file mode 100644 index 0000000..2c49b6a --- /dev/null +++ b/lua/config/options.lua @@ -0,0 +1,28 @@ +local opt = vim.opt + +opt.termguicolors = true +opt.number = true +opt.relativenumber = true +opt.tabstop = 2 +opt.shiftwidth = 2 +opt.wrap = false +opt.expandtab = true +opt.smartindent = true +opt.ignorecase = true +opt.smartcase = true +opt.scrolloff = 8 +opt.sidescrolloff = 8 +opt.cursorline = true +opt.signcolumn = "yes" +opt.splitbelow = true +opt.splitright = true +opt.hlsearch = true +opt.incsearch = true +opt.clipboard = "unnamedplus" +opt.completeopt = "menuone,noselect" +opt.updatetime = 50 +opt.swapfile = false +opt.backup = false +opt.undofile = true +opt.splitright = true +opt.splitbelow = true diff --git a/lua/plugins/automkdir.lua b/lua/plugins/automkdir.lua new file mode 100644 index 0000000..09c04d4 --- /dev/null +++ b/lua/plugins/automkdir.lua @@ -0,0 +1,4 @@ +return { + "mateuszwieloch/automkdir.nvim", + opts = {}, +} diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua new file mode 100644 index 0000000..c96d365 --- /dev/null +++ b/lua/plugins/autopairs.lua @@ -0,0 +1,18 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = { + check_ts = true, + ts_config = { + lua = { "string" }, + javascript = { "template_string" } + }, + }, + config = function (_, opts) + local npairs = require("nvim-autopairs") + npairs.setup(opts) + local cmp_autopairs = require("nvim-autopairs.completion.cmp") + local cmp = require("cmp") + cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) + end +} diff --git a/lua/plugins/cheatsheet.lua b/lua/plugins/cheatsheet.lua new file mode 100644 index 0000000..7ef7981 --- /dev/null +++ b/lua/plugins/cheatsheet.lua @@ -0,0 +1,15 @@ +return { + "sudormrfbin/cheatsheet.nvim", + cmd = { "Cheatsheet" }, + dependencies = { + "nvim-telescope/telescope.nvim", + "nvim-lua/popup.nvim", + "nvim-lua/plenary.nvim", + }, + config = function() + require("cheatsheet").setup({ + bundled_cheatsheets = true, + bundled_plugin_cheatsheets = true, + }) + end, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..12d233b --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,6 @@ +return { + "numToStr/comment.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = {}, + lazy = false +} diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua new file mode 100644 index 0000000..fa534f1 --- /dev/null +++ b/lua/plugins/completion.lua @@ -0,0 +1,40 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + config = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = false }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + }, { + { name = "buffer" }, + }), + }) + end, +} + diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 0000000..5575a06 --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,42 @@ +return { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + keys = { + { + "cf", + function() + require("conform").format({ async = true, lsp_fallback = true }) + end, + desc = "Format buffer" + }, + { + "cF", + function() + require("conform").format({ formatters = { "injected" } }) + end, + desc = "Format injected langs" + }, + }, + opts = { + formatters_by_ft = { + javascript = { "prettier" }, + typescript = { "prettier" }, + javascriptreact = { "prettier" }, + typescriptreact = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, + json = { "prettier" }, + yaml = { "prettier" }, + markdown = { "prettier" }, + lua = { "stylelua" }, + python = { "black" }, + php = { "php_cs_fixer" }, + go = { "gofmt" }, + rurst = { "rustfmt" }, + }, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true + } + } +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..d4234f7 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,38 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "" }, + topdelete = { text = "" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + on_attach = function(buffer) + local gs = package.loaded.gitsigns + local function map(mode, l, r, desc) + vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + end + map("n", "gh", gs.prev_hunk, "Previous hunk") + map("n", "gl", gs.next_hunk, "Next hunk") + -- Git actions + map("n", "ga", gs.stage_hunk, "Add/stage hunk") + map("n", "gr", gs.reset_hunk, "Reset hunk") + map("n", "gA", gs.stage_buffer, "Add/stage all") + map("n", "gR", gs.reset_buffer, "Reset all") + map("n", "gu", gs.undo_stage_hunk, "Undo stage") + map("n", "gp", gs.preview_hunk, "Preview hunk") + map("n", "gb", function() gs.blame_line({ full = true }) end, "Blame line") + map("n", "gd", gs.diffthis, "Diff this") + map("n", "gD", function() gs.diffthis("~") end, "Diff this ~") + map("n", "gt", gs.toggle_deleted, "Toggle deleted") + -- Visual mode + map("v", "ga", function() gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Add/stage") + map("v", "gr", function() gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end, "Reset") + -- Text object + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "Select hunk") + end, + }, +} diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua new file mode 100644 index 0000000..89ffa33 --- /dev/null +++ b/lua/plugins/indent-blankline.lua @@ -0,0 +1,24 @@ +return { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + event = { "BufReadPost", "BufNewFile" }, + opt = { + indent = { + char = "|", + tab_char = "|" + }, + scope = { + enabled = true, + show_start = false, + show_end = false, + }, + exlude = { + filetypes = { + "help", + "lazy", + "mason", + "notify", + }, + }, + }, +} diff --git a/lua/plugins/index.lua b/lua/plugins/index.lua new file mode 100644 index 0000000..863ded7 --- /dev/null +++ b/lua/plugins/index.lua @@ -0,0 +1,20 @@ +return { + -- Install Order + -- 1. Treesitter [✓] + -- 2. LSP Minimal [✓] + -- 3. Completions [✓] + -- 4. Autopairs [✓] + -- 5. Telescope [✓] + -- 6. Which-Key [✓] + -- 7. Comment [✓] + -- 8. Surround + -- 9. Vim-Sleuth + -- 10. Nvim-Lint + -- 11. Git-Signs + -- 12. Lualine + -- 13. Ident-Blankline + -- 14. Autommkdir | Mkdir + -- 15. Cheatsheet | neodev + -- 16. Replace | Simple Format + -- 17. vim-be-good +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..09560a8 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,117 @@ +return { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "hrsh7th/cmp-nvim-lsp", + }, + config = function() + require("mason").setup() + local capabilities = require("cmp_nvim_lsp").default_capabilities() + local lspconfig = require("lspconfig") + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(event) + local map = function(keys, func, desc) + vim.keymap.set("n", keys, func, {buffer = event.buf, desc = desc}) + end + -- Navigation + map("gd", vim.lsp.buf.definition, "Go to definition") + map("gD", vim.lsp.buf.declaration, "Go to declatation") + map("gi", vim.lsp.buf.implementation, "Go to implementation") + map("gr", vim.lsp.buf.definition, "Go to references") + map("gt", vim.lsp.buf.type_definition, "Go to type definition") + -- Documentation + map("K", vim.lsp.buf.hover, "Hover documentation") + map("K", vim.lsp.buf.signature_help, "Signature help") + -- LSP Actions + map("ca", vim.lsp.buf.code_action, "Code action") + map("cr", vim.lsp.buf.rename, "Rename") + map("cf", vim.lsp.buf.format, "Format") + -- Diagnostics + map("do", vim.diagnostic.open_float, "Show diagnostics") + map("dl", vim.diagnostic.goto_next, "Next diagnostic") + map("dh", vim.diagnostic.goto_prev, "Previous diagnostic") + map("dF", vim.diagnostic.setloclist, "Quickfix diagnostics") + map("da", vim.diagnostic.setloclist, "List diagnostics") + end, + }) + + local servers = { + -- Javascript/TypeScript/React + ts_ls = { + settings = { + typescript = { + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + }, + }, + }, + }, + -- Hyprland + hyprls = {}, + -- CSS/SCSS + cssls = {}, + -- stylelint + stylelint_lsp = {}, + -- HTML + html = {}, + -- PHP + intelephense = { + settings = { + php = { + validate = { + enable = true, + run = "onSave", + }, + }, + }, + }, + -- Python + pyright = {}, + -- JSON + jsonls = {}, + -- TOML + taplo = {}, + -- YAML + yamlls = {}, + -- Rust + rust_analyzer = { + settings = { + ["rust_analyzer"] = { + check = { + command = "clippy" + }, + }, + }, + }, + -- Go + gopls = {}, + -- Markdown + marksman = {}, + -- Lua + lua_ls = { + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, + }, + } + require("mason-lspconfig").setup({ + ensure_installed = vim.tbl_keys(servers), + handlers = { + function(server_name) + local config = servers[server_name] or {} + config.capabilities = capabilities + lspconfig[server_name].setup(config) + end, + }, + }) + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..1f9264f --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,253 @@ +return { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + dependencies = { + "nvim-tree/nvim-web-devicons" + }, + config = function() + local lualine = require("lualine") + local colors = { + lime = "#71f79f", + red = "#ed254e", + orange = "#ff6a00", + yellow = "#f9dc5c", + purple = "#c74ded", + dark_purple = "#7b7bbd", + blue = "#7cb7ff", + cyan = "#00c1e4", + teal = "#00e8c6", + watermelon = "#ff4d7a", + white = "#fefefe", + text = "#c3c7d1", + subtext1 = "#a8b2c0", + subtext0 = "#8a96a8", + base = "#161925", + mantle = "#121520", + surface0 = "#1a1f2e", + surface1 = "#222e39", + surface2 = "#31363d", + } + local conditions = { + buffer_not_empty = function() + return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 + end, + hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end, + check_git_workspace = function() + local filepath = vim.fn.expand("%:p:h") + local gitdir = vim.fn.finddir(".git", filepath .. ";") + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, + is_code_file = function() + local ft = vim.bo.filetype + return ft == "javascript" or ft == "typescript" or ft == "lua" or ft == "python" or ft == "jsx" or ft == "tsx" + end, + } + local config = { + options = { + component_separators = "", + section_separators = "", + theme = { + normal = { c = { fg = colors.fg, bg = colors.bg } }, + inactive = { c = { fg = colors.fg, bg = colors.bg } }, + }, + }, + sections = { + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + } + local function ins_left(component) + table.insert(config.sections.lualine_c, component) + end + local function ins_right(component) + table.insert(config.sections.lualine_x, component) + end + -- Left Side + -- Component: Mode + ins_left { + "mode", + color = function() + local mode_color = { + n = colors.lime, + i = colors.blue, + v = colors.purple, + [''] = colors.purple, + V = colors.purple, + c = colors.yellow, + R = colors.red, + t = colors.teal + } + return { bg = colors.mantle, fg = mode_color[vim.fn.mode()], gui = "bold" } + end, + padding = { left = 1, right = 1 } + } + -- Separator Mode->Filename + ins_left { + function() return "" end, + color = { fg = colors.mantle, bg = colors.orange }, + padding = 0 + } + -- Component: Filename + ins_left { + "filename", + path = 1, + shorting_target = 32, + file_status = true, + symbols = { + modified = "[+]", + readonly = "[RO]", + unnamed = "[No Name]" + }, + cond = conditions.buffer_not_empty, + color = { fg = colors.mantle, bg = colors.orange, gui = "bold" }, + padding = { left = 1, right = 1 } + } + -- Seperator Filename -> Git + ins_left { + function() return "" end, + color = { fg = colors.orange, bg = colors.lime }, + padding = 0 + } + -- Component: Git Branch + ins_left { + "branch", + color = { fg = colors.mantle, bg = colors.lime }, + padding = { left = 1, right = 1 } + } + -- Component: Git diff status + ins_left { + "diff", + symbols = { + added = '+', + modified = '!', + removed = '-' + }, + diff_color = { + added = { fg = colors.bg, bg = colors.lime }, + modified = { fg = colors.dark_purple, bg = colors.lime }, + removed = { fg = colors.red, bg = colors.lime }, + }, + cond = conditions.check_git_workspace, + padding = { left = 0, right = 1 }, + } + -- Seperator Git -> Function + ins_left { + function() return "" end, + color = { fg = colors.lime, bg = colors.watermelon }, + padding = 0 + } + -- Component: Current Function + ins_left { + function() + local ft = vim.bo.filetype + local is_code_file = ft == "javascript" or ft == "typescript" or ft == "lua" or ft == "python" or ft == "jsx" or + ft == "tsx" + if not is_code_file then + return "" + end + local ts_utils = require("nvim-treesitter.ts_utils") + local current_node = ts_utils.get_node_at_cursor() + if not current_node then return "" end + local function_node = current_node + while function_node do + local node_type = function_node:type() + if node_type == "function_declaration" or + node_type == "function_expression" or + node_type == "arrow_function" or + node_type == "method_definition" then + break + end + function_node = function_node:parent() + end + if function_node then + local name_node = function_node:field("name")[1] + if name_node then + local name = vim.treesitter.get_node_text(name_node, 0) + return name:sub(1, 20) + end + end + return "󰈙" + end, + icon = "󰊕", + color = { fg = colors.mantle, bg = colors.watermelon, gui = "bold" }, + } + -- Seperator End + ins_left { + function() return "" end, + color = { fg = colors.watermelon, bg = colors.surface1 }, + padding = { left = 0, right = 1 } + } + -- Right Side + -- Seperator Start + ins_right { + function() return "" end, + color = { fg = colors.teal, bg = colors.surface1 }, + padding = 0 + } + -- Component: Encoding + ins_right { + "encoding", + color = { fg = colors.mantle, bg = colors.teal, gui = "bold" }, + } + -- Component: Filetype + ins_right { + "filetype", + color = { fg = colors.mantle, bg = colors.teal, gui = "bold" }, + } + -- Separator: Filetype -> LSP Status + ins_right { + function() return "" end, + color = { fg = colors.dark_purple, bg = colors.teal }, + padding = 0 + } + -- Component: LSP Status + ins_right { + "lsp_status", + color = { fg = colors.text, bg = colors.dark_purple, gui = "bold" } + } + -- Seperator: LSP Status -> Diagnostics + ins_right { + function() return "" end, + color = { bg = colors.dark_purple, fg = colors.surface0 }, + padding = 0 + } + -- Component: Diagnostics + ins_right { + "diagnostics", + always_visible = true, + symbols = { + error = "[E]", + warn = "[W]", + info = "[I]", + hint = "[H]" + }, + color = { bg = colors.surface0, gui = "bold" } + } + -- Seperator: Diagnostics -> Location + ins_right { + function() return "" end, + color = { fg = colors.white, bg = colors.surface0 }, + padding = 0 + } + -- Component: Location + ins_right { + "location", + color = { fg = colors.mantle, bg = colors.white, gui = "bold" } + } + lualine.setup(config) + end, +} diff --git a/lua/plugins/sleuth.lua b/lua/plugins/sleuth.lua new file mode 100644 index 0000000..2985281 --- /dev/null +++ b/lua/plugins/sleuth.lua @@ -0,0 +1,4 @@ +return { + "tpope/vim-sleuth", + event = { "BufReadPre", "BufNewFile" } +} diff --git a/lua/plugins/surround.lua b/lua/plugins/surround.lua new file mode 100644 index 0000000..4da94cf --- /dev/null +++ b/lua/plugins/surround.lua @@ -0,0 +1,6 @@ +return { + "kylechui/nvim-surround", + version = "*", + event = "VeryLazy", + opts = {} +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..cad4146 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,44 @@ +return { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + dependencies = { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make" + }, + }, + keys = { + -- File Finding + { "ff", "Telescope find_files", desc = "Files" }, + { "fr", "Telescope oldfiles", desc = "Recent files" }, + { "fg", "Telescope live_grep", desc = "Grep text" }, + { "fw", "Telescope grep_string", desc = "Current word" }, + { "fb", "Telescope buffers", desc = "Buffers" }, + { "f?", "Telescope help_tags", desc = "Help pages" }, + { "fk", "Telescope keymaps", desc = "Keymaps" }, + { "fc", "Telescope commands", desc = "Commands" }, + { "fo", "Telescope vim_options", desc = "Options" }, + { "fm", "Telescope marks", desc = "Marks" }, + -- Git + { "gs", "Telescope git_status", desc = "Status" }, + { "gc", "Telescope git_commits", desc = "Commits" }, + { "gb", "Telescope git_branches", desc = "Branches" }, + -- Search + { "sr", "Telescope resume", desc = "Resume last search" }, + { "sw", "Telescope grep_string", desc = "Current word" }, + { "sd", "Telescope diagnostics", desc = "Diagnostics" }, + }, + opts = { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + path_display = { "truncate" } + }, + }, + config = function(_, opts) + local telescope = require("telescope") + telescope.setup(opts) + telescope.load_extension("fzf") + end, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..2ae446f --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,37 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = { "BufReadPost", "BufNewFile" }, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { + "lua", + "vim", + "vimdoc", + "hyprlang", + "nginx", + "yaml", + "bash", + "toml", + "regex", + "comment", + "json", + "html", + "xml", + "css", + "javascript", + "typescript", + "tsx", + "markdown", + "markdown_inline", + "sql", + "graphql", + "go", + "rust", + }, + auto_install = true, + highlight = { enable = true}, + indent = { enable = true}, + }) + end, +} diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 0000000..41c55bb --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + "mbbill/undotree", + config = function () + vim.keymap.set("n", "z", vim.cmd.UndotreeToggle, { desc = "Toggle untotree" }) + end +} diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 0000000..0de5337 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,14 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + preset = "classic", + plugins = { + presets = { + operators = true, + motions = true, + text_objects = true + }, + }, + }, +}