Something went wrong. Try again.
My simple neovim config
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268local github = function(repo) return "https://github.com/" .. repoend
vim.g.mapleader = ","vim.opt.winborder = "rounded"vim.opt.relativenumber = truevim.opt.number = truevim.opt.spelllang = "en"-- Global optionsvim.opt.termguicolors = truevim.opt.hidden = truevim.opt.hlsearch = falsevim.opt.incsearch = truevim.opt.scrolloff = 8vim.opt.splitright = truelocal tab_value = 4vim.opt.tabstop = tab_valuevim.opt.softtabstop = tab_valuevim.opt.shiftwidth = tab_valuevim.opt.expandtab = true
vim.opt.shell = "fish"vim.opt.bg = "dark"vim.opt.spell = false -- Enables treesitter comment spellingvim.opt.termguicolors = truevim.opt.signcolumn = "yes"vim.opt.filetype = "on"vim.o.swapfile = falsevim.o.wrap = falsevim.o.clipboard = "unnamedplus"vim.opt.cmdheight = 1vim.opt.laststatus = 3
-- Persistent undosvim.opt.undofile = truevim.filetype.add({ extension = { service = "systemd", templ = "templ" }, pattern = { [".*/%.github/workflows/.*.yml"] = "yaml.github", [".*/%.github/workflows/.*.yaml"] = "yaml.github", },})vim.opt.packpath:prepend(vim.fn.stdpath("data") .. "/site")
vim.pack.add({ { src = github("mrcjkb/rustaceanvim"), version = vim.version.range("^9") }, github("Saecki/crates.nvim"), github("ziglang/zig.vim"), github("EdenEast/nightfox.nvim"), github("folke/which-key.nvim"), github("folke/snacks.nvim"), github("echasnovski/mini.icons"), github("folke/lsp-trouble.nvim"), github("stevearc/conform.nvim"), github("nvim-lualine/lualine.nvim"), github("nvim-treesitter/nvim-treesitter"), github("nvim-treesitter/nvim-treesitter-context"),}, { confirm = false, load = true })
local nts = require("nvim-treesitter")local ts_parsers = { "astro", "bash", "c", "dockerfile", "gitcommit", "go", "gomod", "lua", "python", "query", "rust", "toml", "yaml", "just",}local installed_parsers = nts.get_installed("parsers")local missing_parsers = vim.tbl_filter(function(parser) return not vim.list_contains(installed_parsers, parser)end, ts_parsers)if #missing_parsers > 0 then nts.install(missing_parsers)endvim.api.nvim_create_autocmd("PackChanged", { callback = function(event) if event.data.spec.name == "nvim-treesitter" and (event.data.kind == "install" or event.data.kind == "update") then nts.update() end end,})vim.api.nvim_create_autocmd("FileType", { pattern = ts_parsers, callback = function() pcall(vim.treesitter.start) end,})
require("snacks").setup({ input = {}, picker = { sources = { files = { hidden = true, exclude = { "*.lock", ".env*" }, }, grep = { hidden = true, exclude = { "*.lock", ".env*" }, }, }, }, indent = { animate = { enabled = false, }, }, explorer = {}, notifier = {},})
require("mini.icons").setup()require("trouble").setup()
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { pattern = "Cargo.toml", once = true, callback = function() require("crates").setup({ lsp = { enabled = true, actions = true, completion = true, hover = true, }, }) end,})vim.api.nvim_create_autocmd("BufReadPost", { callback = function(args) local mark = vim.api.nvim_buf_get_mark(args.buf, '"') local line_count = vim.api.nvim_buf_line_count(args.buf) if mark[1] > 0 and mark[1] <= line_count then vim.api.nvim_win_set_cursor(0, mark) -- defer centering slightly so it's applied after render vim.schedule(function() vim.cmd("normal! zz") end) end end,})require("which-key").setup()require("lualine").setup({ options = { component_separators = { left = "|", right = "|" }, section_separators = "", },})vim.cmd.colorscheme("carbonfox")
local conform_folder = "/Users/ethan/Documents/work/openfe/openfe"local cwd = vim.fs.normalize(vim.loop.cwd() or "")conform_folder = vim.fs.normalize(conform_folder)if cwd:sub(1, #conform_folder) ~= conform_folder then require("conform").setup({ formatters_by_ft = { lua = { "stylua" }, python = { "ruff_format" }, terraform = { "tofu_fmt" }, astro = { "prettierd", "prettier", stop_after_first = true }, svelte = { "prettierd", "prettier", stop_after_first = true }, typescript = { "prettierd", "prettier", stop_after_first = true }, javascript = { "prettierd", "prettier", stop_after_first = true }, }, format_on_save = { timeout_ms = 500, lsp_fallback = true, }, })end
require("mappings")vim.cmd("set completeopt+=noselect")vim.lsp.enable({ "lua_ls", "gh_actions_ls", "gopls", "astro", "nixd", "zls", "ruff", "tflint", "just", "ty", "templ", "terraformls", "nil_ls", "ts_ls", "tombi", "yamlls", "harper_ls",})vim.g.rustaceanvim = { server = { on_attach = function(client, _) client.server_capabilities.workspace.didChangeWatchedFiles = { dynamicRegistration = false, } end, default_settings = { ["rust-analyzer"] = { files = { watcherExclude = { "**/.direnv/**", }, excludeDirs = { ".direnv", ".github", }, }, cargo = { features = "all", }, }, }, },}
vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) local client = vim.lsp.get_client_by_id(ev.data.client_id) if client ~= nil and client:supports_method("textDocument/completion") then vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true }) end end,})
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})vim.api.nvim_create_autocmd("LspAttach", { group = "LspAttach_inlayhints", callback = function(event) local client = vim.lsp.get_client_by_id(event.data.client_id) -- Enable for all clients except for lua_ls if client and client.name ~= "lua_ls" then vim.lsp.inlay_hint.enable(true) end end,})
vim.api.nvim_create_autocmd({ "FileType" }, { group = vim.api.nvim_create_augroup("edit_text", { clear = true }), pattern = { "gitcommit", "markdown", "txt" }, desc = "Enable spell checking and text wrapping for certain filetypes", callback = function() vim.opt_local.spell = true end,})vim.opt.spell = false
vim.diagnostic.config({ -- update_in_insert = false, virtual_text = true, virtual_lines = { current_line = true },})