-- Bootstrap local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local uv = vim.uv or vim.loop if not uv.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", "https://github.com/folke/lazy.nvim.git", lazypath, }) end vim.opt.rtp:prepend(lazypath) -- Globals vim.g.mapleader = " " vim.g.maplocalleader = " " -- Plugins require("lazy").setup({ "tpope/vim-sleuth", { "rainglow/vim", lazy = false, priority = 1000, }, { "nvim-tree/nvim-web-devicons", lazy = true, }, { "windwp/nvim-autopairs", config = function() local npairs = require("nvim-autopairs") npairs.setup({}) local Rule = require("nvim-autopairs.rule") npairs.remove_rule("`") npairs.add_rule(Rule("`", "`") :with_pair(function(opts) return opts.filetype ~= "markdown" end)) end, }, { "nvim-mini/mini.indentscope", version = false, opts = { symbol = "│", draw = { predicate = function(scope) return vim.bo.filetype ~= "snacks_dashboard" and not scope.body.is_incomplete end, }, options = { try_as_border = true, }, mappings = { object_scope = "", object_scope_with_border = "", goto_top = "", goto_bottom = "", }, }, config = function(_, opts) require("mini.indentscope").setup(opts) vim.api.nvim_create_autocmd("FileType", { pattern = { "snacks_dashboard", "Trouble", "lazy", "mason", "help", }, callback = function() vim.b.miniindentscope_disable = true end, }) vim.api.nvim_create_autocmd("User", { pattern = "SnacksDashboardOpened", callback = function() vim.b.miniindentscope_disable = true end, }) end, }, { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons", }, config = function() require("telescope").setup({ defaults = { prompt_prefix = "󰱼 ", selection_caret = "❯ ", }, pickers = { find_files = { file_ignore_patterns = { "build/", "builddir/", "_build/", "ext/", "vendor/", }, }, }, }) end, }, { "nvim-treesitter/nvim-treesitter", branch = "main", lazy = false, }, { "folke/snacks.nvim", priority = 1000, lazy = false, opts = { indent = { enabled = false, }, dashboard = { enabled = true, preset = { header = [[ ██████╗ ██████╗ ██╗ ██╗██╗ ██╗ ██╔══██╗██╔══██╗██║ ██║██║ ██║ ██████╔╝██████╔╝██║ ██║███████║ ██╔══██╗██╔══██╗██║ ██║██╔══██║ ██████╔╝██║ ██║╚██████╔╝██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ]], keys = { { icon = "󰱼 ", key = "f", desc = "Find File", action = ":Telescope find_files", }, { icon = "󰈙 ", key = "n", desc = "New File", action = ":enew", }, { icon = "󰋚 ", key = "r", desc = "Recent Files", action = ":Telescope oldfiles", }, { icon = "󰊢 ", key = "g", desc = "Find Text", action = ":Telescope live_grep", }, { icon = "󰒲 ", key = "l", desc = "Lazy", action = ":Lazy", }, { icon = "󰅚 ", key = "q", desc = "Quit", action = ":qa", }, }, }, }, }, }, { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim", }, opts = { signs = true, keywords = { FIX = { icon = "󰆴 " }, TODO = { icon = "󰔰 " }, HACK = { icon = "󰈸 " }, WARN = { icon = "󰀪 " }, NOTE = { icon = "󰋽 " }, }, }, }, { "folke/trouble.nvim", opts = {}, }, { "nvimdev/lspsaga.nvim", dependencies = { "nvim-tree/nvim-web-devicons", }, opts = { ui = { border = "rounded", }, lightbulb = { enable = false, }, symbol_in_winbar = { enable = false, }, hover = { max_width = 0.8, max_height = 0.6, }, code_action = { show_server_name = false, }, }, }, { "hrsh7th/nvim-cmp", dependencies = { "hrsh7th/cmp-nvim-lsp", "saadparwaiz1/cmp_luasnip", "L3MON4D3/LuaSnip", "rafamadriz/friendly-snippets", }, config = function() local cmp = require("cmp") local luasnip = require("luasnip") local icons = { Text = "󰉿", Method = "󰆧", Function = "󰊕", Constructor = "", Field = "󰜢", Variable = "󰀫", Class = "󰠱", Interface = "", Module = "", Property = "󰜢", Unit = "󰑭", Value = "󰎠", Enum = "", Keyword = "󰌋", Snippet = "", Color = "󰏘", File = "󰈙", Reference = "󰈇", Folder = "󰉋", EnumMember = "", Constant = "󰏿", Struct = "󰙅", Event = "", Operator = "󰆕", TypeParameter = "󰊄", } require("luasnip.loaders.from_vscode").lazy_load() 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.confirm({ select = true }), [""] = cmp.mapping.complete(), }), formatting = { format = function(_, item) item.kind = icons[item.kind] or "" return item end, }, sources = { { name = "nvim_lsp" }, { name = "luasnip" }, }, }) end, }, { "neovim/nvim-lspconfig", dependencies = { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", "hrsh7th/cmp-nvim-lsp", "j-hui/fidget.nvim", }, config = function() require("mason").setup() require("fidget").setup() vim.lsp.config("*", { capabilities = require("cmp_nvim_lsp").default_capabilities(), }) vim.lsp.config("lua_ls", { settings = { Lua = { diagnostics = { globals = { "vim" }, }, completion = { callSnippet = "Replace", }, }, }, }) vim.lsp.config("rust_analyzer", { settings = { ["rust-analyzer"] = { cargo = { buildScripts = { enable = true, }, }, procMacro = { enable = true, }, }, }, }) local servers = { "lua_ls", "rust_analyzer", } require("mason-tool-installer").setup({ ensure_installed = servers, }) require("mason-lspconfig").setup({ automatic_enable = true, }) end, }, { "lewis6991/gitsigns.nvim", opts = { signs = { add = { text = "▎" }, change = { text = "▎" }, delete = { text = "󰍵" }, topdelete = { text = "‾" }, changedelete = { text = "󰍵" }, }, }, }, { "folke/which-key.nvim", config = function() require("which-key").setup() require("which-key").add({ { "f", group = "Find", icon = "󰱼" }, { "c", group = "Code", icon = "󰆧" }, { "d", group = "Diagnostics", icon = "󰒓" }, { "x", group = "Trouble", icon = "󰒓" }, }) end, }, }) -- Diagnostics for type, icon in pairs({ Error = "󰅚 ", Warn = "󰀪 ", Info = "󰋽 ", Hint = "󰌶 ", }) do vim.fn.sign_define("DiagnosticSign" .. type, { text = icon, texthl = "Diagnostic" .. type, }) end vim.diagnostic.config({ virtual_text = true, signs = true, underline = true, severity_sort = true, float = { border = "rounded", }, }) -- Options local opt = vim.opt opt.number = true opt.mouse = "a" opt.splitright = true opt.splitbelow = true opt.autoindent = true opt.smartindent = true opt.expandtab = true opt.shiftwidth = 4 opt.tabstop = 4 opt.ignorecase = true opt.smartcase = true opt.termguicolors = true opt.linebreak = true opt.scrolloff = 10 opt.clipboard = "unnamedplus" opt.laststatus = 0 opt.showmode = true opt.showcmd = false opt.ruler = false opt.completeopt = { "menu", "menuone", "noinsert", "noselect", } opt.fillchars:append({ vert = " ", eob = " ", }) -- Commands vim.cmd([[ cnoreabbrev W w cnoreabbrev Q q cnoreabbrev WQ wq cnoreabbrev Wq wq cnoreabbrev wQ wq cnoreabbrev WQA wqa cnoreabbrev WQa wqa cnoreabbrev Wqa wqa ]]) -- Autocommands vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank() end, }) -- Keymaps local map = vim.keymap.set local telescope = require("telescope.builtin") -- General map("n", "", "nohlsearch") map({ "n", "v" }, "j", "gj") map({ "n", "v" }, "k", "gk") -- Telescope map("n", "ff", telescope.find_files, { desc = "Find files", }) map("n", "fg", telescope.live_grep, { desc = "Find text", }) map("n", "fb", telescope.buffers, { desc = "Find buffers", }) -- Diagnostics map("n", "[d", vim.diagnostic.goto_prev, { desc = "Previous diagnostic", }) map("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic", }) map("n", "d", vim.diagnostic.open_float, { desc = "Show diagnostic", }) -- Trouble map("n", "xx", "Trouble diagnostics toggle", { desc = "Diagnostics", }) map("n", "xq", "Trouble qflist toggle", { desc = "Quickfix list", }) map("n", "xl", "Trouble loclist toggle", { desc = "Location list", }) map("n", "xr", "Trouble lsp_references toggle", { desc = "References", }) -- LSP map("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition", }) map("n", "gr", vim.lsp.buf.references, { desc = "Find references", }) map("n", "K", "Lspsaga hover_doc", { desc = "Hover documentation", }) map("n", "rn", "Lspsaga rename", { desc = "Rename symbol", }) map("n", "ca", "Lspsaga code_action", { desc = "Code action", }) -- Appearance vim.cmd.colorscheme("bold-contrast") for _, group in ipairs({ "Normal", "NormalNC", "SignColumn", "CursorLine", "StatusLine", "StatusLineNC", "MsgArea", "MsgSeparator", "TabLine", "TabLineFill", }) do vim.api.nvim_set_hl(0, group, { bg = "NONE", }) end vim.api.nvim_set_hl(0, "EndOfBuffer", { fg = "NONE", bg = "NONE", }) vim.api.nvim_set_hl(0, "LineNr", { fg = "#555555", bg = "NONE", }) vim.api.nvim_set_hl(0, "CursorLineNr", { fg = "#aaaaaa", bg = "NONE", bold = true, }) vim.api.nvim_set_hl(0, "VertSplit", { fg = "NONE", bg = "NONE", }) vim.api.nvim_set_hl(0, "WinSeparator", { fg = "NONE", bg = "NONE", }) vim.api.nvim_set_hl(0, "Visual", { bg = "#222222", }) vim.api.nvim_set_hl(0, "Search", { bg = "#222222", }) vim.api.nvim_set_hl(0, "IncSearch", { bg = "#333333", }) vim.api.nvim_set_hl(0, "PMenu", { bg = "#222222", }) vim.api.nvim_set_hl(0, "PMenuSel", { bg = "#333333", bold = true, }) -- Telescope vim.api.nvim_set_hl(0, "TelescopeNormal", { fg = "#aaaaaa", bg = "NONE", }) vim.api.nvim_set_hl(0, "TelescopeBorder", { fg = "#555555", bg = "NONE", }) vim.api.nvim_set_hl(0, "TelescopePromptNormal", { fg = "#b0b0b0", bg = "NONE", }) vim.api.nvim_set_hl(0, "TelescopeResultsNormal", { fg = "#aaaaaa", bg = "NONE", }) vim.api.nvim_set_hl(0, "TelescopePreviewNormal", { fg = "#aaaaaa", bg = "NONE", }) vim.api.nvim_set_hl(0, "TelescopeSelection", { fg = "#dddddd", bg = "#222222", bold = true, }) -- Lspsaga vim.api.nvim_set_hl(0, "SagaNormal", { bg = "NONE", }) vim.api.nvim_set_hl(0, "SagaBorder", { fg = "#555555", bg = "NONE", }) -- Current indent scope vim.api.nvim_set_hl(0, "MiniIndentscopeSymbol", { fg = "#666666", })