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) vim.g.mapleader = " " vim.g.maplocalleader = " " require("lazy").setup({ "tpope/vim-sleuth", "lukas-reineke/indent-blankline.nvim", "andreasvc/vim-256noir", "windwp/nvim-autopairs", { "stevearc/oil.nvim", opts = { default_file_explorer = true, view_options = { show_hidden = true, }, }, }, { "nvim-lualine/lualine.nvim", opts = { options = { globalstatus = true, component_separators = "", section_separators = "", }, inactive_sections = { lualine_a = {}, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, lualine_z = {}, }, }, config = function(_, opts) local function fg(group, fallback) local ok, hl = pcall(vim.api.nvim_get_hl, 0, { name = group, link = false }) if ok and hl.fg then return string.format("#%06x", hl.fg) end return fallback end local text = fg("Normal", "#b4b7ad") local accent = fg("Statement", "#f0624b") local cool = fg("Function", "#3d8e91") -- teal local warm = fg("String", "#f7a21b") -- orange opts.sections = { lualine_a = {}, lualine_b = {}, lualine_c = { { "mode", color = { fg = accent, bg = "NONE", gui = "bold" } }, { "filename", color = { fg = text } }, }, lualine_x = { { "branch", color = { fg = cool } }, { "diagnostics", symbols = { error = "E:", warn = "W:", info = "I:", hint = "H:" }, -- no color override: lualine tints each severity from the theme }, }, lualine_y = {}, lualine_z = { { "location", color = { fg = warm } }, }, } local none = { fg = text, bg = "NONE" } local mirror = { a = none, b = none, c = none } opts.options.theme = { normal = mirror, insert = mirror, visual = mirror, replace = mirror, command = mirror, inactive = mirror, } require("lualine").setup(opts) vim.api.nvim_set_hl(0, "StatusLine", { bg = "NONE" }) vim.api.nvim_set_hl(0, "StatusLineNC", { bg = "NONE" }) end, }, -- Telescope { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" }, config = function() require("telescope").setup({ pickers = { find_files = { file_ignore_patterns = { "^build/", "^builddir/", "^_build/", "^ext/", "^vendor/", }, }, }, }) end, }, { "nvim-treesitter/nvim-treesitter", branch = "master", lazy = false, build = ":TSUpdate", config = function() require("nvim-treesitter.configs").setup({ highlight = { enable = true }, indent = { enable = false }, ensure_installed = { "lua", "vim", "c", "cpp", "markdown", "python", "rust", "bash", }, }) end, }, { "folke/snacks.nvim", priority = 1000, lazy = false, opts = { indent = { enabled = true, indent = { enabled = false, }, scope = { enabled = false, }, chunk = { enabled = true, hl = "Comment", char = { corner_top = "┌", corner_bottom = "└", horizontal = "─", vertical = "│", arrow = "→", }, }, }, }, }, -- Completion { "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") require("luasnip.loaders.from_vscode").lazy_load() cmp.setup({ -- No automatic completion popup. completion = { autocomplete = false, }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, }, mapping = cmp.mapping.preset.insert({ -- Accept selected completion. [""] = cmp.mapping.confirm({ select = true, }), -- Manually open completion. [""] = cmp.mapping.complete(), -- Navigate completion menu. [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.select_prev_item(), -- Close completion menu. [""] = cmp.mapping.abort(), }), sources = { { name = "nvim_lsp" }, { name = "luasnip" }, }, }) end, }, -- LSP { "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() -- Per-server settings. Mason installs these; Neovim's native LSP -- (vim.lsp.config / vim.lsp.enable) configures and starts them. local servers = { lua_ls = { settings = { Lua = { diagnostics = { globals = { "vim" } }, completion = { callSnippet = "Replace" }, }, }, }, rust_analyzer = { settings = { ["rust-analyzer"] = { cargo = { buildScripts = { enable = true } }, procMacro = { enable = true }, }, }, }, } -- Advertise nvim-cmp completion capabilities to every server. vim.lsp.config("*", { capabilities = require("cmp_nvim_lsp").default_capabilities(), }) -- Merge each server's settings on top of nvim-lspconfig's defaults. for name, cfg in pairs(servers) do vim.lsp.config(name, cfg) end -- Install the servers (mason-tool-installer), then auto-enable the -- installed ones via vim.lsp.enable (mason-lspconfig v2). require("mason-tool-installer").setup({ ensure_installed = vim.tbl_keys(servers), }) require("mason-lspconfig").setup({ automatic_enable = true, }) end, }, -- Formatting { "stevearc/conform.nvim", opts = { notify_on_error = false, formatters_by_ft = { lua = { "stylua" }, python = { "black" }, -- rustfmt reads the edition from Cargo.toml (defaults to 2021) -- and respects rustfmt.toml, so no extra args are needed. rust = { "rustfmt" }, }, }, }, -- Git signs ASCII { "lewis6991/gitsigns.nvim", config = function() require("gitsigns").setup({ signs = { add = { text = "+" }, change = { text = "~" }, delete = { text = "-" }, topdelete = { text = "-" }, changedelete = { text = "~" }, }, }) end, }, -- Which-key { "folke/which-key.nvim", config = function() require("which-key").setup() end, }, }) -- ASCII diagnostics vim.fn.sign_define("DiagnosticSignError", { text = "E", texthl = "DiagnosticError" }) vim.fn.sign_define("DiagnosticSignWarn", { text = "W", texthl = "DiagnosticWarn" }) vim.fn.sign_define("DiagnosticSignInfo", { text = "I", texthl = "DiagnosticInfo" }) vim.fn.sign_define("DiagnosticSignHint", { text = "H", texthl = "DiagnosticHint" }) -- 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.cursorline = false opt.linebreak = true opt.scrolloff = 10 opt.clipboard = "unnamedplus" opt.completeopt = { "menu", "menuone", "noinsert", "noselect" } -- Typo forgiveness 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 ]]) -- Keymaps local map = vim.keymap.set map("n", "", ":nohl") map("n", "-", require("oil").open, { desc = "Open parent directory" }) map("n", "", function() require("oil").open(vim.fn.getcwd()) end, { desc = "Browse working directory" }) local telescope = require("telescope.builtin") 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" }) map("n", "cf", function() require("conform").format({ async = true, lsp_format = "fallback" }) end, { desc = "Format buffer" }) vim.diagnostic.config({ virtual_text = true, signs = true, underline = true, severity_sort = true, }) vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank() end, }) vim.cmd.colorscheme("256_noir") vim.cmd([[ highlight Normal guibg=NONE ctermbg=NONE highlight NormalNC guibg=NONE ctermbg=NONE highlight SignColumn guibg=NONE ctermbg=NONE highlight EndOfBuffer guibg=NONE ctermbg=NONE highlight LineNr guibg=NONE ctermbg=NONE highlight CursorLineNr guibg=NONE ctermbg=NONE highlight CursorLine guibg=NONE ctermbg=NONE highlight StatusLine guibg=NONE ctermbg=NONE highlight StatusLineNC guibg=NONE ctermbg=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 = "#222222" }) vim.api.nvim_set_hl(0, "PMenu", { bg = "#222222" }) vim.api.nvim_set_hl(0, "PMenySelf", { bg = "#333333", bold=true })