diff --git a/_home_adam_.config_nvim b/_home_adam_.config_nvim new file mode 100644 index 00000000..27c99652 --- /dev/null +++ b/_home_adam_.config_nvim @@ -0,0 +1,62 @@ +let SessionLoad = 1 +let s:so_save = &g:so | let s:siso_save = &g:siso | setg so=0 siso=0 | setl so=-1 siso=-1 +let v:this_session=expand(":p") +silent only +silent tabonly +cd ~/.config/nvim +if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == '' + let s:wipebuf = bufnr('%') +endif +let s:shortmess_save = &shortmess +if &shortmess =~ 'A' + set shortmess=aoOA +else + set shortmess=aoO +endif +badd +1 ~/.config/nvim/lua/core/keymaps.lua +argglobal +%argdel +edit ~/.config/nvim/lua/core/keymaps.lua +wincmd t +let s:save_winminheight = &winminheight +let s:save_winminwidth = &winminwidth +set winminheight=0 +set winheight=1 +set winminwidth=0 +set winwidth=1 +argglobal +setlocal fdm=manual +setlocal fde=0 +setlocal fmr={{{,}}} +setlocal fdi=# +setlocal fdl=0 +setlocal fml=1 +setlocal fdn=20 +setlocal fen +silent! normal! zE +let &fdl = &fdl +let s:l = 1 - ((0 * winheight(0) + 17) / 35) +if s:l < 1 | let s:l = 1 | endif +keepjumps exe s:l +normal! zt +keepjumps 1 +normal! 0 +tabnext 1 +if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal' + silent exe 'bwipe ' . s:wipebuf +endif +unlet! s:wipebuf +set winheight=1 winwidth=20 +let &shortmess = s:shortmess_save +let &winminheight = s:save_winminheight +let &winminwidth = s:save_winminwidth +let s:sx = expand(":p:r")."x.vim" +if filereadable(s:sx) + exe "source " . fnameescape(s:sx) +endif +let &g:so = s:so_save | let &g:siso = s:siso_save +set hlsearch +nohlsearch +doautoall SessionLoadPost +unlet SessionLoad +" vim: set ft=vim : diff --git a/build.zen b/build.zen new file mode 100644 index 00000000..97511545 --- /dev/null +++ b/build.zen @@ -0,0 +1,44 @@ +// +// The Zen Programming Language(tm) +// Copyright (c) 2018-2020 kristopher tate & connectFree Corporation. +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// +// This project may be licensed under the terms of the ConnectFree Reference +// Source License (CF-RSL). Corporate and Academic licensing terms are also +// available. Please contact for details. +// +// Zen, the Zen three-circles logo and The Zen Programming Language are +// trademarks of connectFree Corporation in Japan and other countries. +// +// connectFree and the connectFree logo are registered trademarks +// of connectFree Corporation in Japan and other countries. connectFree +// trademarks and branding may not be used without express written permission +// of connectFree. Please remove all trademarks and branding before use. +// +// See the LICENSE file at the root of this project for complete information. +// +// + +const Builder = @import("std").build.Builder; + +pub fn build(b: *mut Builder) void { + // Standard target options allows the person running `zen build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + // Standard release options allow the person running `zen build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. + const mode = b.standardReleaseOptions(); + + const exe = b.addExecutable("nvim", "src/main.zen"); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.install(); + + const run_cmd = exe.run(); + b.addStepDependency(run_cmd, b.getInstallStep()); + + const run_step = b.step("run", "Run the app"); + b.addStepDependency(run_step, run_cmd); +} diff --git a/init.lua b/init.lua index c607bf05..80713364 100644 --- a/init.lua +++ b/init.lua @@ -8,7 +8,12 @@ require 'options.settings' local plugins = require 'plugins' -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +-- Set leader key before lazy.nvim +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Bootstrap lazy.nvim +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 } diff --git a/lua/options/autocmds.lua b/lua/options/autocmds.lua new file mode 100644 index 00000000..50e78134 --- /dev/null +++ b/lua/options/autocmds.lua @@ -0,0 +1,23 @@ +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- Auto format Go files on save +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + vim.lsp.buf.format({ async = false }) + end, +}) + +-- Auto format Zig files on save +vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.zig", + callback = function() + vim.lsp.buf.format({ async = false }) + end, +}) diff --git a/lua/options/gitsigns.lua b/lua/options/gitsigns.lua new file mode 100644 index 00000000..4f5441c7 --- /dev/null +++ b/lua/options/gitsigns.lua @@ -0,0 +1,12 @@ +return { -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + }, +} diff --git a/lua/options/settings.lua b/lua/options/settings.lua new file mode 100644 index 00000000..4ceab1ea --- /dev/null +++ b/lua/options/settings.lua @@ -0,0 +1,75 @@ +-- [[ Setting options ]] +-- See `:help vim.opt` +-- NOTE: You can change these options as you wish! +-- For more options, you can see `:help option-list` + +-- Make line numbers default +vim.opt.number = true +vim.o.relativenumber = true +-- You can also add relative line numbers, to help with jumping. +-- Experiment for yourself to see if you like it! +-- vim.opt.relativenumber = true + +-- Enable mouse mode, can be useful for resizing splits for example! +vim.opt.mouse = 'a' + +-- Don't show the mode, since it's already in the status line +vim.opt.showmode = false + +-- Sync clipboard between OS and Neovim. +-- Schedule the setting after `UiEnter` because it can increase startup-time. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.schedule(function() + vim.opt.clipboard = 'unnamedplus' +end) + +-- Enable break indent +vim.opt.breakindent = true + +-- Save undo history +vim.opt.undofile = true + +-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term +vim.opt.ignorecase = true +vim.opt.smartcase = true + +-- Keep signcolumn on by default +vim.opt.signcolumn = 'yes' + +-- Decrease update time +vim.opt.updatetime = 250 + +-- Decrease mapped sequence wait time +vim.opt.timeoutlen = 300 + +-- Configure how new splits should be opened +vim.opt.splitright = true +vim.opt.splitbelow = true + +-- Disable word wrap +vim.opt.wrap = false + +-- Sets how neovim will display certain whitespace characters in the editor. +-- See `:help 'list'` +-- and `:help 'listchars'` +vim.opt.list = true +vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' } + +-- Preview substitutions live, as you type! +vim.opt.inccommand = 'split' + +-- Show which line your cursor is on +vim.opt.cursorline = true + +-- Minimal number of screen lines to keep above and below the cursor. +vim.opt.scrolloff = 10 + +-- Disable winbar +vim.opt.winbar = "" + +-- Set diagnostic signs +vim.fn.sign_define("DiagnosticSignError", { text = "", texthl = "DiagnosticSignError" }) +vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) +vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) +vim.fn.sign_define("DiagnosticSignHint", { text = "󰌵", texthl = "DiagnosticSignHint" }) diff --git a/lua/plugins/blink-cmp.lua b/lua/plugins/blink-cmp.lua new file mode 100644 index 00000000..d1ec77a6 --- /dev/null +++ b/lua/plugins/blink-cmp.lua @@ -0,0 +1,12 @@ +return { + 'saghen/blink.cmp', + dependencies = 'rafamadriz/friendly-snippets', + version = '*', + opts = { + keymap = { preset = 'default' }, + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = 'mono', + }, + }, +} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua new file mode 100644 index 00000000..ce8af4b9 --- /dev/null +++ b/lua/plugins/bufferline.lua @@ -0,0 +1,56 @@ +return { + 'akinsho/bufferline.nvim', + version = "*", + dependencies = 'nvim-tree/nvim-web-devicons', + opts = { + options = { + mode = "buffers", -- set to "tabs" to only show tabpages instead + numbers = "none", + close_command = "bdelete! %d", -- can be a string | function, | false see "Mouse actions" + right_mouse_command = "bdelete! %d", -- can be a string | function | false, see "Mouse actions" + left_mouse_command = "buffer %d", -- can be a string | function, | false see "Mouse actions" + middle_mouse_command = nil, -- can be a string | function, | false see "Mouse actions" + indicator = { + icon = '▎', -- this should be omitted if indicator style is not 'icon' + style = 'icon', + }, + buffer_close_icon = '󰅖', + modified_icon = '●', + close_icon = '', + left_trunc_marker = '', + right_trunc_marker = '', + max_name_length = 30, + max_prefix_length = 30, + truncate_names = true, + tab_size = 21, + diagnostics = "nvim_lsp", + diagnostics_update_in_insert = false, + diagnostics_indicator = function(count, level, diagnostics_dict, context) + return "("..count..")" + end, + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + text_align = "left", + separator = true + } + }, + color_icons = true, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + show_duplicate_prefix = true, + persist_buffer_sort = true, + separator_style = "thin", + enforce_regular_tabs = false, + always_show_bufferline = true, + hover = { + enabled = true, + delay = 200, + reveal = {'close'} + }, + } + } +} diff --git a/lua/plugins/coding.lua b/lua/plugins/coding.lua new file mode 100644 index 00000000..5e6f59b4 --- /dev/null +++ b/lua/plugins/coding.lua @@ -0,0 +1,252 @@ +return { + -- Go development + { + "ray-x/go.nvim", + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup({ + -- Gopls configuration + lsp_cfg = { + settings = { + gopls = { + analyses = { + unusedparams = true, + shadow = true, + }, + staticcheck = true, + gofumpt = true, + usePlaceholders = true, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + }, + }, + }, + -- Format on save + gofmt = "gofumpt", + -- Import on save + goimports = true, + -- Enable linters + linter = "golangci-lint", + -- Test settings + test_runner = "go", + test_flags = {"-v"}, + -- Debug settings + dap_debug = true, + dap_debug_gui = true, + }) + + -- Run gofmt + goimports on save + local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {}) + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.go", + callback = function() + require("go.format").goimports() + end, + group = format_sync_grp, + }) + end, + event = {"CmdlineEnter"}, + ft = {"go", "gomod"}, + build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries + }, + + -- Zig development + { + "ziglang/zig.vim", + ft = "zig", + config = function() + -- Enable auto-formatting on save + vim.g.zig_fmt_autosave = 1 + end, + }, + + -- C development + { + "p00f/clangd_extensions.nvim", + dependencies = { + "neovim/nvim-lspconfig", + }, + ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + opts = { + inlay_hints = { + inline = false, + }, + ast = { + role_icons = { + type = "🄣", + declaration = "🄓", + expression = "🄔", + statement = ";", + specifier = "🄢", + ["template argument"] = "🆃", + }, + kind_icons = { + Compound = "🄲", + Recovery = "🅁", + TranslationUnit = "🅄", + PackExpansion = "🄿", + TemplateTypeParm = "🅃", + TemplateTemplateParm = "🅃", + TemplateParamObject = "🅃", + }, + }, + }, + }, + + -- DAP (Debug Adapter Protocol) + { + "mfussenegger/nvim-dap", + dependencies = { + "rcarriga/nvim-dap-ui", + "theHamsta/nvim-dap-virtual-text", + "leoluz/nvim-dap-go", -- Go debug adapter + "nvim-neotest/nvim-nio", -- Required by nvim-dap-ui + }, + config = function() + local dap = require("dap") + local dapui = require("dapui") + + -- Set up Go debugging + require("dap-go").setup() + + -- Set up Python debugging + dap.adapters.python = { + type = 'executable', + command = 'debugpy-adapter', + } + + dap.configurations.python = { + { + type = 'python', + request = 'launch', + name = "Launch file", + program = "${file}", + pythonPath = function() + -- Try to detect python path from active virtual environment + if vim.env.VIRTUAL_ENV then + return vim.env.VIRTUAL_ENV .. "/bin/python" + end + -- Return system python if no venv + return '/usr/bin/python3' + end, + }, + } + + -- Set up C debugging with codelldb + dap.adapters.codelldb = { + type = 'server', + port = "${port}", + executable = { + command = 'codelldb', + args = {"--port", "${port}"}, + } + } + + dap.configurations.c = { + { + name = "Launch file", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopOnEntry = false, + args = {}, + }, + } + + -- Set up UI + dapui.setup({ + layouts = { + { + elements = { + { id = "scopes", size = 0.25 }, + { id = "breakpoints", size = 0.25 }, + { id = "stacks", size = 0.25 }, + { id = "watches", size = 0.25 }, + }, + position = "left", + size = 40 + }, + { + elements = { + { id = "repl", size = 0.5 }, + { id = "console", size = 0.5 }, + }, + position = "bottom", + size = 10 + }, + }, + }) + + -- Automatically open UI + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end + + -- Add keymaps + vim.keymap.set("n", "pb", dap.toggle_breakpoint, { desc = "Toggle Breakpoint" }) + vim.keymap.set("n", "pc", dap.continue, { desc = "Continue Debug" }) + vim.keymap.set("n", "pn", dap.step_over, { desc = "Step Over" }) + vim.keymap.set("n", "pi", dap.step_into, { desc = "Step Into" }) + vim.keymap.set("n", "po", dap.step_out, { desc = "Step Out" }) + vim.keymap.set("n", "pr", dap.repl.open, { desc = "Debug REPL" }) + vim.keymap.set("n", "pl", dap.run_last, { desc = "Run Last Debug" }) + vim.keymap.set("n", "px", dapui.toggle, { desc = "Toggle Debug UI" }) + + -- Profiling commands + local function profile_go() + local file = vim.fn.expand('%:p') + local cmd = string.format('go test -cpuprofile cpu.prof -memprofile mem.prof -bench . %s', file) + vim.fn.system(cmd) + vim.cmd('split term://go tool pprof -http=:8080 cpu.prof') + end + + local function profile_python() + local file = vim.fn.expand('%:p') + local cmd = string.format('py-spy record -o profile.svg -f speedscope -- python %s', file) + vim.fn.system(cmd) + vim.cmd('!xdg-open profile.svg') + end + + local function profile_c() + local file = vim.fn.expand('%:p:r') -- Get file path without extension + local cmd = string.format('perf record -g ./%s && perf report -g graph', file) + vim.cmd('split term://' .. cmd) + end + + -- Add profiling keymaps based on filetype + vim.api.nvim_create_autocmd("FileType", { + pattern = { "go", "python", "c", "cpp" }, + callback = function() + local ft = vim.bo.filetype + if ft == "go" then + vim.keymap.set("n", "mp", profile_go, { buffer = true, desc = "Profile Go code" }) + elseif ft == "python" then + vim.keymap.set("n", "mp", profile_python, { buffer = true, desc = "Profile Python code" }) + elseif ft == "c" or ft == "cpp" then + vim.keymap.set("n", "mp", profile_c, { buffer = true, desc = "Profile C/C++ code" }) + end + end, + }) + end, + }, +} diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 00000000..b7b0c09e --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,42 @@ +return { -- Autoformat + 'stevearc/conform.nvim', + event = { 'BufWritePre' }, + cmd = { 'ConformInfo' }, + keys = { + { + 'f', + function() + require('conform').format { async = true, lsp_format = 'fallback' } + end, + mode = '', + desc = '[F]ormat buffer', + }, + }, + opts = { + notify_on_error = false, + format_on_save = function(bufnr) + -- Disable "format_on_save lsp_fallback" for languages that don't + -- have a well standardized coding style. You can add additional + -- languages here or re-enable it for the disabled ones. + local disable_filetypes = { c = true, cpp = true } + local lsp_format_opt + if disable_filetypes[vim.bo[bufnr].filetype] then + lsp_format_opt = 'never' + else + lsp_format_opt = 'fallback' + end + return { + timeout_ms = 500, + lsp_format = lsp_format_opt, + } + end, + formatters_by_ft = { + lua = { 'stylua' }, + -- Conform can also run multiple formatters sequentially + -- python = { "isort", "black" }, + -- + -- You can use 'stop_after_first' to run the first available formatter from the list + -- javascript = { "prettierd", "prettier", stop_after_first = true }, + }, + }, +} diff --git a/lua/plugins/dadbod.lua b/lua/plugins/dadbod.lua new file mode 100644 index 00000000..b99ce4c1 --- /dev/null +++ b/lua/plugins/dadbod.lua @@ -0,0 +1,67 @@ +-- Database explorer and query runner +return { + 'tpope/vim-dadbod', + dependencies = { + 'kristijanhusak/vim-dadbod-ui', -- UI for vim-dadbod + 'kristijanhusak/vim-dadbod-completion' -- Completion for SQL + }, + cmd = { + 'DBUI', + 'DBUIToggle', + 'DBUIAddConnection', + 'DBUIFindBuffer', + }, + init = function() + -- Save DBUI settings + vim.g.db_ui_save_location = vim.fn.stdpath("data") .. "/db_ui" + vim.g.db_ui_use_nerd_fonts = true + vim.g.db_ui_execute_on_save = false -- Don't auto-execute queries on save + vim.g.db_ui_table_helpers = { + -- Add useful SQL snippets + mysql = { + List = 'SELECT * FROM {table} LIMIT 100', + Indexes = 'SHOW INDEXES FROM {table}', + Foreign = 'SELECT * FROM information_schema.key_column_usage WHERE referenced_table_name = {table}', + }, + postgresql = { + List = 'SELECT * FROM {table} LIMIT 100', + Indexes = 'SELECT * FROM pg_indexes WHERE tablename = {table}', + Foreign = [[ + SELECT + tc.table_schema, + tc.constraint_name, + tc.table_name, + kcu.column_name, + ccu.table_schema AS foreign_table_schema, + ccu.table_name AS foreign_table_name, + ccu.column_name AS foreign_column_name + FROM + information_schema.table_constraints AS tc + JOIN information_schema.key_column_usage AS kcu + ON tc.constraint_name = kcu.constraint_name + AND tc.table_schema = kcu.table_schema + JOIN information_schema.constraint_column_usage AS ccu + ON ccu.constraint_name = tc.constraint_name + AND ccu.table_schema = tc.table_schema + WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name={table}; + ]], + }, + } + end, + config = function() + -- Enable SQL completion in SQL files and dadbod-ui buffers + vim.api.nvim_create_autocmd('FileType', { + pattern = {'sql', 'mysql', 'plsql', 'pgsql'}, + callback = function() + -- Set up completion + require('cmp').setup.buffer({ + sources = { + { name = 'vim-dadbod-completion' }, -- Database-aware completion + { name = 'nvim_lsp' }, -- LSP completion + { name = 'buffer' }, -- Buffer words + }, + }) + end, + }) + end, +} diff --git a/lua/plugins/garbage-day.lua b/lua/plugins/garbage-day.lua new file mode 100644 index 00000000..25134296 --- /dev/null +++ b/lua/plugins/garbage-day.lua @@ -0,0 +1,21 @@ +-- Garbage collector that stops inactive LSP clients to free RAM +return { + 'zeioth/garbage-day.nvim', + dependencies = 'neovim/nvim-lspconfig', + event = 'VeryLazy', + opts = { + -- Collect garbage after 10 minutes of inactivity + grace_period = 60 * 10, + -- Exclude null-ls and other special clients + excluded_lsp_clients = { 'omnisharp', 'null-ls', 'none-ls' }, + -- Show notifications when clients are stopped + notifications = true, + -- Garbage collection settings + aggressive_mode = false, -- Be gentle with GC + -- Adjust Lua's GC parameters for better performance + gc_settings = { + pause = 110, -- Lower pause for more frequent but shorter GC pauses + step_mul = 100, -- Lower step multiplier for smoother collection + }, + }, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 00000000..64f83e07 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,35 @@ +return { -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + config = function() + require('gitsigns').setup({ + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '-' }, + topdelete = { text = '-' }, + changedelete = { text = '~' }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + preview_config = { + -- Options passed to nvim_open_win + border = 'single', + style = 'minimal', + relative = 'cursor', + row = 0, + col = 1 + }, + }) + end, +} diff --git a/lua/plugins/gruvbox.lua b/lua/plugins/gruvbox.lua new file mode 100644 index 00000000..40f77dd4 --- /dev/null +++ b/lua/plugins/gruvbox.lua @@ -0,0 +1,17 @@ +return { -- You can easily change to a different colorscheme. + -- Change the name of the colorscheme plugin below, and then + -- change the command in the config to whatever the name of that colorscheme is. + -- + -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. + 'ellisonleao/gruvbox.nvim', + priority = 1000, -- Make sure to load this before all the other start plugins. + init = function() + -- Load the colorscheme here. + -- Like many other themes, this one has different styles, and you could load + -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. + vim.cmd.colorscheme 'gruvbox' + + -- You can configure highlights by doing something like: + vim.cmd.hi 'Comment gui=none' + end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 00000000..26392782 --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,12 @@ +local plugins = {} + +local plugin_files = vim.fn.globpath(vim.fn.stdpath('config') .. '/lua/plugins', '*.lua', false, true) + +for _, file in ipairs(plugin_files) do + local plugin_name = file:match('.*/(.*)%.lua$') + if plugin_name ~= 'init' then + table.insert(plugins, require('plugins.' .. plugin_name)) + end +end + +return plugins diff --git a/lua/plugins/lazydev.lua b/lua/plugins/lazydev.lua new file mode 100644 index 00000000..6d9c256b --- /dev/null +++ b/lua/plugins/lazydev.lua @@ -0,0 +1,12 @@ +return { + -- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + 'folke/lazydev.nvim', + ft = 'lua', + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = 'luvit-meta/library', words = { 'vim%.uv' } }, + }, + }, +} diff --git a/lua/plugins/leap.lua b/lua/plugins/leap.lua new file mode 100644 index 00000000..9f8ef2c4 --- /dev/null +++ b/lua/plugins/leap.lua @@ -0,0 +1,25 @@ +-- Quick navigation plugin +return { + 'ggandor/leap.nvim', + dependencies = { + 'tpope/vim-repeat', -- For dot-repeat support + }, + config = function() + local leap = require('leap') + + -- Basic setup + leap.setup { + case_sensitive = false, + safe_labels = {}, -- Show all labels + labels = { + 'f', 'j', 'd', 'k', 's', 'l', 'h', 'g', + 'F', 'J', 'D', 'K', 'S', 'L', 'H', 'G', + }, + } + + -- Set highlight colors for better visibility + vim.api.nvim_set_hl(0, 'LeapMatch', { fg = '#89B4FA', bold = true, nocombine = true }) + vim.api.nvim_set_hl(0, 'LeapLabelPrimary', { fg = '#F38BA8', bold = true, nocombine = true }) + vim.api.nvim_set_hl(0, 'LeapLabelSecondary', { fg = '#94E2D5', bold = true, nocombine = true }) + end, +} diff --git a/lua/plugins/luvit-meta.lua b/lua/plugins/luvit-meta.lua new file mode 100644 index 00000000..da6ddc73 --- /dev/null +++ b/lua/plugins/luvit-meta.lua @@ -0,0 +1 @@ +return { 'Bilal2453/luvit-meta', lazy = true } diff --git a/lua/plugins/mason-null-ls.lua b/lua/plugins/mason-null-ls.lua new file mode 100644 index 00000000..a94e7253 --- /dev/null +++ b/lua/plugins/mason-null-ls.lua @@ -0,0 +1,18 @@ +return { + "jay-babu/mason-null-ls.nvim", + enabled = true, + dependencies = { + "williamboman/mason.nvim", + "nvimtools/none-ls.nvim", -- replaces null-ls + }, + config = function() + require("mason-null-ls").setup({ + ensure_installed = + { + "prettier", + "eslint" + }, + automatic_installation = true, + }) + end, +} diff --git a/lua/plugins/mini-icons.lua b/lua/plugins/mini-icons.lua new file mode 100644 index 00000000..b6a0bdbe --- /dev/null +++ b/lua/plugins/mini-icons.lua @@ -0,0 +1,42 @@ +return { + 'echasnovski/mini.nvim', + version = false, + config = function() + require('mini.icons').setup({ + -- Enable all preset kinds + preset = 'default', + -- Customize icons for specific kinds + devicons = { + enabled = true, + override = { + -- File types + default = '', + lua = '', + python = '', + javascript = '', + html = '', + css = '', + json = '', + yaml = '', + toml = '', + markdown = '', + -- Git + git = '', + github = '', + gitlab = '', + gitignore = '', + -- Folders + folder = '', + folder_open = '', + folder_empty = '', + folder_empty_open = '', + -- LSP + error = '', + warning = '', + info = '', + hint = '󰌵', + }, + }, + }) + end, +} diff --git a/lua/plugins/mini-surround.lua b/lua/plugins/mini-surround.lua new file mode 100644 index 00000000..0050bc37 --- /dev/null +++ b/lua/plugins/mini-surround.lua @@ -0,0 +1,11 @@ +return { + 'echasnovski/mini.surround', + version = '*', + event = "VeryLazy", + config = function() + require('mini.surround').setup({ + -- Use mappings from centralized keymaps + mappings = require('core.keymaps').mini_surround_keymaps + }) + end, +} diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua deleted file mode 100644 index a8b4c30e..00000000 --- a/lua/plugins/mini.lua +++ /dev/null @@ -1,218 +0,0 @@ -return { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } - - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - - -- Session management - local session = require('mini.sessions') - - -- Function to safely restore LSP state - local function safe_restore_lsp() - -- Disable semantic tokens temporarily during session load - local semantic_tokens = {} - for _, client in pairs(vim.lsp.get_active_clients()) do - semantic_tokens[client.id] = client.server_capabilities.semanticTokensProvider - client.server_capabilities.semanticTokensProvider = nil - end - - -- Return a function to restore semantic tokens - return function() - for id, tokens in pairs(semantic_tokens) do - local client = vim.lsp.get_client_by_id(id) - if client then - client.server_capabilities.semanticTokensProvider = tokens - end - end - end - end - - -- Get session name based on current directory - local function get_session_name() - local cwd = vim.fn.getcwd() - -- Replace path separators and spaces with underscores - local name = string.gsub(cwd, '[/\\%s]', '_') - return name - end - - -- Clean up buffers before saving session - local function pre_save() - -- Store current buffers - local bufs = vim.api.nvim_list_bufs() - - -- Close special buffers that we don't want to save - for _, buf in ipairs(bufs) do - if vim.api.nvim_buf_is_valid(buf) then - local buftype = vim.api.nvim_buf_get_option(buf, 'buftype') - local filetype = vim.api.nvim_buf_get_option(buf, 'filetype') - if buftype ~= '' or filetype == 'TelescopePrompt' or filetype == 'neo-tree' then - vim.api.nvim_buf_delete(buf, { force = true }) - end - end - end - end - - -- Clean up after loading session - local function post_load() - -- Close any empty buffers that might have been created - local bufs = vim.api.nvim_list_bufs() - for _, buf in ipairs(bufs) do - if vim.api.nvim_buf_is_valid(buf) then - local buftype = vim.api.nvim_buf_get_option(buf, 'buftype') - local filetype = vim.api.nvim_buf_get_option(buf, 'filetype') - local modified = vim.api.nvim_buf_get_option(buf, 'modified') - local name = vim.api.nvim_buf_get_name(buf) - - if not modified and (name == '' or buftype ~= '' or filetype == 'TelescopePrompt' or filetype == 'neo-tree') then - vim.api.nvim_buf_delete(buf, { force = true }) - end - end - end - end - - -- Create session functions for use in keymaps - _G.MiniSession = { - save = function() - local name = get_session_name() - local ok, err = pcall(function() session.write(name) end) - if ok then - vim.notify(string.format('Session: Successfully saved "%s"', name), - vim.log.levels.INFO) - else - vim.notify(string.format('Session: Failed to save "%s": %s', name, err), - vim.log.levels.ERROR) - end - end, - - load = function() - local name = get_session_name() - local ok, err = pcall(function() session.read(name) end) - if ok then - vim.notify(string.format('Session: Successfully loaded "%s"', name), - vim.log.levels.INFO) - else - vim.notify(string.format('Session: Failed to load "%s": %s', name, err), - vim.log.levels.ERROR) - end - end, - - delete = function() - local name = get_session_name() - local ok, err = pcall(function() session.delete(name) end) - if ok then - vim.notify(string.format('Session: Successfully deleted "%s"', name), - vim.log.levels.INFO) - else - vim.notify(string.format('Session: Failed to delete "%s": %s', name, err), - vim.log.levels.ERROR) - end - end - } - - -- Create session directory - local session_dir = vim.fn.stdpath('data') .. '/sessions' - if vim.fn.isdirectory(session_dir) == 0 then - vim.fn.mkdir(session_dir, 'p') - end - - session.setup({ - -- Directory to store session files - directory = session_dir, - -- File to use for current session - file = get_session_name(), - -- Whether to force write session file on each write operation - force_write = true, - -- Hook functions for actions - hooks = { - -- Before loading a session - pre_load = function() - -- Clean up buffers safely - for _, buf in ipairs(vim.api.nvim_list_bufs()) do - local ft = vim.api.nvim_buf_get_option(buf, 'filetype') - -- Don't close special buffers - if ft ~= 'NvimTree' and ft ~= 'neo-tree' and ft ~= 'TelescopePrompt' then - pcall(vim.api.nvim_buf_delete, buf, { force = false }) - end - end - return safe_restore_lsp() - end, - -- After loading a session - post_load = function() - post_load() - -- Restore LSP semantic tokens after a short delay - vim.defer_fn(function() - if vim.v.vim_did_enter == 1 then - for _, client in pairs(vim.lsp.get_active_clients()) do - if client.server_capabilities.semanticTokensProvider then - vim.lsp.semantic_tokens.force_refresh(client.id) - end - end - end - end, 1000) - vim.notify('Session loaded!', vim.log.levels.INFO) - end, - -- Before saving a session - pre_save = function() - vim.notify('Saving session...', vim.log.levels.INFO) - pre_save() - end, - -- After saving a session - post_save = nil, - }, - -- Whether to read latest session if Neovim opened without file arguments - autoread = false, - -- Whether to write current session before quitting Neovim - autowrite = false, -- We'll handle this ourselves - -- Whether to disable showing non-error feedback - verbose = { - read = false, -- We'll handle our own notifications - write = false, - delete = false, - }, - }) - - -- Update session name when directory changes - vim.api.nvim_create_autocmd('DirChanged', { - callback = function() - session.setup({ file = get_session_name() }) - end, - }) - - -- Auto-save session when leaving Neovim - vim.api.nvim_create_autocmd('VimLeavePre', { - callback = function() - -- Only save if we have buffers - if #vim.fn.getbufinfo({buflisted = 1}) > 0 then - _G.MiniSession.save() - end - end, - }) - end, -} diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua new file mode 100644 index 00000000..ce2dff06 --- /dev/null +++ b/lua/plugins/null-ls.lua @@ -0,0 +1,68 @@ +return { + 'nvimtools/none-ls.nvim', + event = { 'BufReadPre', 'BufNewFile' }, + dependencies = { + 'jay-babu/mason-null-ls.nvim', + }, + config = function() + local null_ls = require 'null-ls' + local null_ls_utils = require 'null-ls.utils' + + local formatting = null_ls.builtins.formatting + local diagnostics = null_ls.builtins.diagnostics + + null_ls.setup { + root_dir = null_ls_utils.root_pattern('.null-ls-root', 'Makefile', '.git'), + timeout = 10000, -- Reduced timeout + debounce = 250, -- Add debounce to prevent excessive updates + update_in_insert = false, -- Only update diagnostics when leaving insert mode + sources = { + -- Go formatting and linting + formatting.gofumpt.with({ + extra_args = { "-extra" }, -- More aggressive formatting + }), + formatting.goimports.with({ + args = { "-local", "", "-w", "$FILENAME" }, -- Optimize imports + }), + diagnostics.golangci_lint.with({ + diagnostics_format = '#{m}', + extra_args = { + '--fast', + '--max-issues-per-linter', '30', + '--max-same-issues', '4', + '--max-same-issues-per-linter', '0', -- Disable duplicate issue reporting per linter + '--fix=false', -- Don't try to fix issues + '--tests=false', -- Don't analyze tests for faster results + '--print-issued-lines=false', -- Don't print the lines that triggered issues + '--timeout=10s', -- Timeout after 10 seconds + '--out-format=json', -- Use JSON format for faster parsing + }, + method = null_ls.methods.DIAGNOSTICS_ON_SAVE, -- Only run on save + timeout = 10000, -- 10 second timeout + }), + + -- Web formatting + formatting.prettier.with { + filetypes = { 'css', 'scss', 'html', 'markdown', 'yaml', 'yml' }, + extra_args = { + '--bracket-same-line', + '--trailing-comma', 'all', + '--tab-width', '2', + '--semi', + '--single-quote', + }, + }, + + -- Shell formatting + formatting.shfmt.with { + extra_args = { '-i', '2', '-ci', '-bn' }, + }, + + -- SQL formatting + formatting.sqlfluff.with { + extra_args = { '--dialect', 'tsql' }, + }, + }, + } + end, +} diff --git a/lua/plugins/nvim-autopairs.lua b/lua/plugins/nvim-autopairs.lua new file mode 100644 index 00000000..4bbf9ea8 --- /dev/null +++ b/lua/plugins/nvim-autopairs.lua @@ -0,0 +1,35 @@ +return { + 'windwp/nvim-autopairs', + event = "InsertEnter", -- Only load in insert mode + opts = { + check_ts = true, + ts_config = { + lua = { "string" }, + javascript = { "template_string" }, + java = false, + }, + ignored_next_char = "[%w%.]", + enable_moveright = false, -- Don't move cursor after pair + enable_afterquote = false, -- Don't add pairs after quotes + enable_check_bracket_line = true, + enable_bracket_in_quote = false, + map_cr = true, + map_bs = true, + map_c_h = false, + map_c_w = false, + disable_in_macro = true, + disable_in_visualblock = true, + enable_abbr = false, + }, + config = function(_, opts) + local npairs = require('nvim-autopairs') + npairs.setup(opts) + + -- Only enable completion integration if cmp is loaded + local ok, cmp = pcall(require, 'cmp') + if ok then + local cmp_autopairs = require('nvim-autopairs.completion.cmp') + cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done()) + end + end, +} diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua new file mode 100644 index 00000000..787e29e9 --- /dev/null +++ b/lua/plugins/nvim-cmp.lua @@ -0,0 +1,115 @@ +return { -- Autocompletion + 'hrsh7th/nvim-cmp', + event = 'InsertEnter', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + 'L3MON4D3/LuaSnip', + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then + return + end + return 'make install_jsregexp' + end)(), + dependencies = { + -- `friendly-snippets` contains a variety of premade snippets. + -- See the README about individual language/framework/plugin snippets: + -- https://github.com/rafamadriz/friendly-snippets + -- { + -- 'rafamadriz/friendly-snippets', + -- config = function() + -- require('luasnip.loaders.from_vscode').lazy_load() + -- end, + -- }, + }, + }, + 'saadparwaiz1/cmp_luasnip', + + -- Adds other completion capabilities. + -- nvim-cmp does not ship with all sources by default. They are split + -- into multiple repos for maintenance purposes. + 'hrsh7th/cmp-nvim-lsp', + 'hrsh7th/cmp-path', + }, + config = function() + -- See `:help cmp` + local cmp = require 'cmp' + local luasnip = require 'luasnip' + luasnip.config.setup {} + + cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = 'menu,menuone,noinsert' }, + + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = cmp.mapping.preset.insert { + -- Select the [n]ext item + [''] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [''] = cmp.mapping.select_prev_item(), + + -- Scroll the documentation window [b]ack / [f]orward + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [''] = cmp.mapping.confirm { select = true }, + + -- If you prefer more traditional completion keymaps, + -- you can uncomment the following lines + --[''] = cmp.mapping.confirm { select = true }, + --[''] = cmp.mapping.select_next_item(), + --[''] = cmp.mapping.select_prev_item(), + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [''] = cmp.mapping.complete {}, + + -- Think of as moving to the right of your snippet expansion. + -- So if you have a snippet that's like: + -- function $name($args) + -- $body + -- end + -- + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [''] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { 'i', 's' }), + + -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: + -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps + }, + sources = { + { + name = 'lazydev', + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + }, + } + end, +} diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua index d5115ff0..fdc330c0 100644 --- a/lua/plugins/nvim-lspconfig.lua +++ b/lua/plugins/nvim-lspconfig.lua @@ -99,8 +99,15 @@ return { lua_ls = { settings = { Lua = { - workspace = { checkThirdParty = false }, - telemetry = { enable = false }, + diagnostics = { + globals = { 'vim' }, + }, + workspace = { + library = { + [vim.fn.expand('$VIMRUNTIME/lua')] = true, + [vim.fn.stdpath('config') .. '/lua'] = true, + }, + }, }, }, }, @@ -115,37 +122,10 @@ return { }, } - -- Setup neovim lua configuration - -- require('neodev').setup({ - -- library = { - -- enabled = true, - -- runtime = true, - -- types = true, - -- plugins = true, - -- }, - -- }) - -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - -- Ensure the servers above are installed - local mason_lspconfig = require 'mason-lspconfig' - - mason_lspconfig.setup { - ensure_installed = vim.tbl_keys(servers), - } - - mason_lspconfig.setup_handlers { - function(server_name) - require('lspconfig')[server_name].setup { - capabilities = capabilities, - settings = servers[server_name] and servers[server_name].settings or {}, - filetypes = servers[server_name] and servers[server_name].filetypes, - } - end, - } - -- Single LSP attach handler for all functionality vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), @@ -200,5 +180,44 @@ return { end end, }) + + -- Ensure the servers above are installed + local mason_lspconfig = require 'mason-lspconfig' + + mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), + } + + mason_lspconfig.setup_handlers { + function(server_name) + local server_config = servers[server_name] or {} + + -- For gopls, disable semantic tokens in capabilities + if server_name == "gopls" then + server_config.capabilities = vim.tbl_deep_extend("force", capabilities, { + textDocument = { + semanticTokens = { + dynamicRegistration = false, + formats = {}, + multilineTokenSupport = false, + overlappingTokenSupport = false, + requests = { + full = false, + range = false, + delta = false + }, + serverCancelSupport = false, + tokenModifiers = {}, + tokenTypes = {} + } + } + }) + else + server_config.capabilities = capabilities + end + + require('lspconfig')[server_name].setup(server_config) + end, + } end, } diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua new file mode 100644 index 00000000..bea35d3a --- /dev/null +++ b/lua/plugins/nvim-treesitter.lua @@ -0,0 +1,25 @@ +return { -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + build = ':TSUpdate', + main = 'nvim-treesitter.configs', -- Sets main module to use for opts + -- [[ Configure Treesitter ]] See `:help nvim-treesitter` + opts = { + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + -- Autoinstall languages that are not installed + auto_install = true, + highlight = { + enable = true, + -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + -- If you are experiencing weird indenting issues, add the language to + -- the list of additional_vim_regex_highlighting and disabled languages for indent. + additional_vim_regex_highlighting = { 'ruby' }, + }, + indent = { enable = true, disable = { 'ruby' } }, + }, + -- There are additional nvim-treesitter modules that you can use to interact + -- with nvim-treesitter. You should go explore a few and see what interests you: + -- + -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` + -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context + -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects +} diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua new file mode 100644 index 00000000..91991713 --- /dev/null +++ b/lua/plugins/snacks.lua @@ -0,0 +1,3 @@ +-- This is the main entry point for snacks configuration +-- All actual configurations are in the snacks/ directory +return require("plugins.snacks.init") diff --git a/lua/plugins/snacks/core.lua b/lua/plugins/snacks/core.lua new file mode 100644 index 00000000..5ba8516e --- /dev/null +++ b/lua/plugins/snacks/core.lua @@ -0,0 +1,34 @@ +return { + bigfile = { enabled = true }, + input = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, -- notifications auto-close after 3s + render = { + max_width = 100, + min_width = 20, + padding = 1, + format = { + default = " {message}", + notify = " {title}\n {message}", + error = " {title}\n {message}", + warn = " {title}\n {message}", + info = " {title}\n {message}", + }, + }, + }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + scratch = { + enabled = true, + float = { + border = "rounded", + width = 0.8, + height = 0.8, + }, + }, + bufdelete = { + enabled = true, + next = "cycle", + }, +} diff --git a/lua/plugins/snacks/dashboard.lua b/lua/plugins/snacks/dashboard.lua new file mode 100644 index 00000000..0f328349 --- /dev/null +++ b/lua/plugins/snacks/dashboard.lua @@ -0,0 +1,19 @@ +return { + dashboard = { + enabled = true, + preset = { + header = [[ + ███▄ █ ▓█████ ▒█████ ██▒ █▓ ██▓ ███▄ ▄███▓ + ██ ▀█ █ ▓█ ▀ ▒██▒ ██▒▓██░ █▒▓██▒▓██▒▀█▀ ██▒ +▓██ ▀█ ██▒▒███ ▒██░ ██▒ ▓██ █▒░▒██▒▓██ ▓██░ +▓██▒ ▐▌██▒▒▓█ ▄ ▒██ ██░ ▒██ █░░░██░▒██ ▒██ +▒██░ ▓██░░▒████▒░ ████▓▒░ ▒▀█░ ░██░▒██▒ ░██▒ +░ ▒░ ▒ ▒ ░░ ▒░ ░░ ▒░▒░▒░ ░ ▐░ ░▓ ░ ▒░ ░ ░ +░ ░░ ░ ▒░ ░ ░ ░ ░ ▒ ▒░ ░ ░░ ▒ ░░ ░ ░ + ░ ░ ░ ░ ░ ░ ░ ▒ ░░ ▒ ░░ ░ + ░ ░ ░ ░ ░ ░ ░ ░ + ░ +]], + }, + }, +} diff --git a/lua/plugins/snacks/display.lua b/lua/plugins/snacks/display.lua new file mode 100644 index 00000000..b2b09560 --- /dev/null +++ b/lua/plugins/snacks/display.lua @@ -0,0 +1,15 @@ +return { + display = { + enabled = true, + indent = { enabled = true }, + references = { enabled = true }, + scope = { enabled = true }, + dim = { enabled = true }, + }, + notifier = { + enabled = true, + timeout = 5000, + max_width = 100, + max_height = 10, + }, +} diff --git a/lua/plugins/snacks/git.lua b/lua/plugins/snacks/git.lua new file mode 100644 index 00000000..61d01a6f --- /dev/null +++ b/lua/plugins/snacks/git.lua @@ -0,0 +1,16 @@ +return { + git = { enabled = true }, + gitbrowse = { + enabled = true, + notify = true, + what = "commit", + }, + lazygit = { + enabled = true, + float = { + border = "rounded", + width = 0.9, + height = 0.9, + }, + }, +} diff --git a/lua/plugins/snacks/init.lua b/lua/plugins/snacks/init.lua new file mode 100644 index 00000000..366e159b --- /dev/null +++ b/lua/plugins/snacks/init.lua @@ -0,0 +1,49 @@ +-- Import all configurations +local core = require("plugins.snacks.core") +local display = require("plugins.snacks.display") +local git = require("plugins.snacks.git") +local terminal = require("plugins.snacks.terminal") +local dashboard = require("plugins.snacks.dashboard") +local picker = require("plugins.snacks.picker") + +-- Merge all configurations +local function merge_tables(...) + local result = {} + for _, t in ipairs({...}) do + for k, v in pairs(t) do + result[k] = v + end + end + return result +end + +-- Return the plugin spec +return { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", -- optional, for file icons + "MunifTanjim/nui.nvim", + "echasnovski/mini.nvim", + }, + ---@type snacks.Config + opts = merge_tables( + core, + display, + git, + terminal, + dashboard, + picker + ), + config = function(_, opts) + -- Initialize snacks with merged options + require("snacks").setup(opts) + + -- Note: Keymaps are handled in core/keymaps.lua + end, + init = function() + -- Make snacks available globally for debugging + _G.Snacks = require("plugins.snacks") + end, +} diff --git a/lua/plugins/snacks/picker.lua b/lua/plugins/snacks/picker.lua new file mode 100644 index 00000000..017da9aa --- /dev/null +++ b/lua/plugins/snacks/picker.lua @@ -0,0 +1,24 @@ +return { + picker = { + sources = { + explorer = { + tree = true, + watch = true, + diagnostics = true, + diagnostics_open = false, + git_status = true, + git_status_open = false, + git_untracked = true, + follow_file = true, + focus = "list", + auto_close = false, + jump = { close = false }, + formatters = { + file = { filename_only = true }, + severity = { pos = "right" }, + }, + matcher = { sort_empty = false, fuzzy = false }, + } + } + }, +} diff --git a/lua/plugins/snacks/terminal.lua b/lua/plugins/snacks/terminal.lua new file mode 100644 index 00000000..3a10808d --- /dev/null +++ b/lua/plugins/snacks/terminal.lua @@ -0,0 +1,10 @@ +return { + terminal = { + enabled = true, + float = { + border = "rounded", + width = 0.8, + height = 0.8, + }, + }, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 00000000..dcbe783e --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,121 @@ +return { -- Fuzzy Finder (files, lsp, etc) + 'nvim-telescope/telescope.nvim', + event = 'VimEnter', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + { -- If encountering errors, see telescope-fzf-native README for installation instructions + 'nvim-telescope/telescope-fzf-native.nvim', + + -- `build` is used to run some command when the plugin is installed/updated. + -- This is only run then, not every time Neovim starts up. + build = 'make', + + -- `cond` is a condition used to determine whether this plugin should be + -- installed and loaded. + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + + -- Useful for getting pretty icons, but requires a Nerd Font. + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + }, + config = function() + -- Telescope is a fuzzy finder that comes with a lot of different things that + -- it can fuzzy find! It's more than just a "file finder", it can search + -- many different aspects of Neovim, your workspace, LSP, and more! + -- + -- The easiest way to use Telescope, is to start by doing something like: + -- :Telescope help_tags + -- + -- After running this command, a window will open up and you're able to + -- type in the prompt window. You'll see a list of `help_tags` options and + -- a corresponding preview of the help. + -- + -- Two important keymaps to use while in Telescope are: + -- - Insert mode: + -- - Normal mode: ? + -- + -- This opens a window that shows you all of the keymaps for the current + -- Telescope picker. This is really useful to discover what Telescope can + -- do as well as how to actually do it! + + -- [[ Configure Telescope ]] + -- See `:help telescope` and `:help telescope.setup()` + require('telescope').setup { + defaults = { + mappings = { + i = { + [''] = 'which_key', -- Show help in insert mode + }, + n = { + ['?'] = 'which_key', -- Show help in normal mode + }, + }, + }, + extensions = { + ['ui-select'] = { + require('telescope.themes').get_dropdown(), + }, + }, + } + + -- Enable Telescope extensions if they are installed + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- Apply Telescope keymaps from our centralized keymaps file + local keymaps = require('core.keymaps').telescope_keymaps + for _, mapping in ipairs(keymaps) do + vim.keymap.set(mapping.mode, mapping.lhs, mapping.rhs, mapping.opts) + end + + -- See `:help telescope.builtin` + local builtin = require 'telescope.builtin' + + -- LSP mappings + vim.keymap.set('n', 'gr', builtin.lsp_references, { desc = 'LSP: [G]oto [R]eferences' }) + vim.keymap.set('n', 'gd', builtin.lsp_definitions, { desc = 'LSP: [G]oto [D]efinition' }) + vim.keymap.set('n', 'gI', builtin.lsp_implementations, { desc = 'LSP: [G]oto [I]mplementation' }) + + -- Regular Telescope mappings + vim.keymap.set('n', 'sh', builtin.help_tags, { desc = '[S]earch [H]elp' }) + vim.keymap.set('n', 'sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' }) + vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) + vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) + vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) + vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) + vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) + + -- Document diagnostics + vim.keymap.set('n', 'dx', builtin.diagnostics, { desc = '[D]ocument Diagnostic[x]' }) + + -- Slightly advanced example of overriding default behavior and theme + vim.keymap.set('n', '/', function() + -- You can pass additional configuration to Telescope to change the theme, layout, etc. + builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) + end, { desc = '[/] Fuzzily search in current buffer' }) + + -- It's also possible to pass additional configuration options. + -- See `:help telescope.builtin.live_grep()` for information about particular keys + vim.keymap.set('n', 's/', function() + builtin.live_grep { + grep_open_files = true, + prompt_title = 'Live Grep in Open Files', + } + end, { desc = '[S]earch [/] in Open Files' }) + + -- Shortcut for searching your Neovim configuration files + vim.keymap.set('n', 'sn', function() + builtin.find_files { cwd = vim.fn.stdpath 'config' } + end, { desc = '[S]earch [N]eovim files' }) + end, +} diff --git a/lua/plugins/todo-comments.lua b/lua/plugins/todo-comments.lua new file mode 100644 index 00000000..c11461df --- /dev/null +++ b/lua/plugins/todo-comments.lua @@ -0,0 +1,9 @@ +return { + 'folke/todo-comments.nvim', + event = 'VimEnter', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { + signs = false, + -- Keymaps are handled in core/keymaps.lua + } +} diff --git a/lua/plugins/vim-sleuth.lua b/lua/plugins/vim-sleuth.lua new file mode 100644 index 00000000..ad6149e8 --- /dev/null +++ b/lua/plugins/vim-sleuth.lua @@ -0,0 +1 @@ +return { 'tpope/vim-sleuth' } diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua new file mode 100644 index 00000000..14b874b5 --- /dev/null +++ b/lua/plugins/which-key.lua @@ -0,0 +1,108 @@ +return { -- Useful plugin to show you pending keybinds. + 'folke/which-key.nvim', + event = 'VimEnter', -- Sets the loading event to 'VimEnter' + opts = { + delay = 0, + icons = { + mappings = vim.g.have_nerd_font, + keys = vim.g.have_nerd_font and {} or { + Up = ' ', + Down = ' ', + Left = ' ', + Right = ' ', + C = ' ', + M = ' ', + D = ' ', + S = ' ', + CR = ' ', + Esc = ' ', + ScrollWheelDown = ' ', + ScrollWheelUp = ' ', + NL = ' ', + BS = ' ', + Space = ' ', + Tab = ' ', + F1 = '', + F2 = '', + F3 = '', + F4 = '', + F5 = '', + F6 = '', + F7 = '', + F8 = '', + F9 = '', + F10 = '', + F11 = '', + F12 = '', + }, + }, + + -- Document existing key chains + spec = { + { 'c', group = '[C]ode', desc = { + a = 'Code [A]ction', + f = '[F]ormat buffer', + }}, + { 'd', group = '[D]ocument', desc = { + x = 'Document [D]iagnostics', + s = 'Document [S]ymbols', + [''] = 'Show diagnostic under cursor', + }}, + { 's', group = '[S]earch', desc = { + h = '[H]elp', + k = '[K]eymaps', + f = '[F]iles', + s = '[S]elect Telescope', + w = 'Current [W]ord', + g = '[G]rep', + d = '[D]iagnostics', + r = '[R]esume last search', + ['.'] = 'Recent files', + ['/'] = 'Search in open files', + n = '[N]eovim config files', + }}, + { 'w', group = '[W]orkspace', desc = { + s = '[S]ymbols', + }}, + { 't', group = '[T]oggle', desc = { + h = 'Toggle inlay [H]ints', + }}, + { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'g', group = '[G]it', desc = { + s = 'Status', + }}, + { 'f', group = '[F]ile Explorer', desc = { + e = 'Toggle explorer', + f = 'Focus explorer', + }}, + { 'n', group = '[N]otifications', desc = { + n = 'Toggle notifications', + h = 'Notification [H]istory', + c = '[C]lear notifications', + }}, + { 'p', group = 'Debug/[P]rofile', desc = { + b = 'Toggle [B]reakpoint', + c = '[C]ontinue debugging', + n = 'Step over ([N]ext)', + i = 'Step [I]nto', + o = 'Step [O]ut', + r = 'Open [R]EPL', + l = 'Run [L]ast debug session', + x = 'Toggle debug UI', + }}, + { 'b', group = '[B]uffer', desc = { + p = '[P]revious', + n = '[N]ext', + d = '[D]elete', + D = 'Force [D]elete', + }}, + { 'q', desc = 'Open diagnostic [Q]uickfix list' }, + { 'e', desc = 'Toggle file [E]xplorer' }, + { 'o', desc = 'F[o]cus file explorer' }, + { 'x', desc = 'Close buffer' }, + { 'X', desc = 'Force close buffer' }, + { '/', desc = 'Search in current buffer' }, + { '', desc = 'Find buffers' }, + }, + }, +} diff --git a/src/main.zen b/src/main.zen new file mode 100644 index 00000000..066a492c --- /dev/null +++ b/src/main.zen @@ -0,0 +1,5 @@ +const std = @import("std"); + +pub fn main() anyerror!void { + std.debug.warn("Congratulations on your first step to writing perfect software in Zen.\n", .{}); +}