vim.opt.number = true vim.opt.relativenumber = true vim.opt.cursorline = true vim.opt.mouse = "" vim.opt.breakindent = true vim.opt.expandtab = true vim.opt.smartcase = true vim.opt.shiftwidth = 4 vim.opt.softtabstop = 4 vim.opt.wildmenu = true vim.opt.undofile = true vim.opt.termguicolors = true vim.opt.shell = "fish" vim.opt.splitbelow = true vim.opt.splitright = true vim.g.mapleader = " " vim.keymap.set("n", "n", "Explore .", {}) -- Per nixvim generated configuration vim.diagnostic.config({ float = { border = "rounded", source = "always" }, virtual_lines = { current_line = true }, virtual_text = false, }) vim.keymap.set("n", "q", function() vim.cmd("hori term") vim.cmd("startinsert") end, {}) vim.keymap.set("t", "", "", {}) vim.pack.add({ "https://github.com/nvim-treesitter/nvim-treesitter", "https://github.com/hrsh7th/nvim-cmp", "https://github.com/hrsh7th/cmp-nvim-lsp", "https://github.com/L3MON4D3/LuaSnip", "https://github.com/hrsh7th/cmp-emoji", "https://github.com/windwp/nvim-autopairs", "https://github.com/lukas-reineke/lsp-format.nvim", "https://github.com/nvimtools/none-ls.nvim", "https://github.com/nvim-lua/plenary.nvim", "https://github.com/nvim-telescope/telescope.nvim", "https://github.com/ej-shafran/compile-mode.nvim", "https://github.com/m00qek/baleia.nvim", "https://github.com/nvim-lualine/lualine.nvim", }) vim.g.compile_mode = { default_command = "nix build", recompile_no_fail = true, buffer_name = "*compile*", baleia_setup = true, } vim.keymap.set("n", "c", function() local id = -1 local bufname = vim.g.compile_mode.buffer_name for _, bufid in ipairs(vim.api.nvim_list_bufs()) do local name = vim.api.nvim_buf_get_name(bufid) if string.sub(name, -string.len(bufname)) == bufname then id = bufid break end end if id == -1 then vim.cmd("Recompile") else vim.bo[id].buflisted = false vim.api.nvim_buf_delete(id, { unload = false }) end end) local file_types = { "rust", "zig", "haskell", "c", "cpp" } require("nvim-treesitter").install(file_types) vim.api.nvim_create_autocmd("FileType", { pattern = file_types, callback = function(ev) vim.treesitter.start(ev.buf) end, }) local telescope = require("telescope.builtin") vim.keymap.set("n", "b", telescope.buffers, {}) vim.keymap.set("n", "f", telescope.find_files, {}) vim.keymap.set("n", "t", telescope.live_grep, {}) vim.keymap.set("n", "m", function() telescope.man_pages({ sections = { "2", "3", "4", "5" }, }) end, {}) require("nvim-autopairs").setup({}) require("null-ls").setup({ on_attach = require("lsp-format").on_attach }) require("lsp-format").setup({}) local luasnip = require("luasnip") local cmp = require("cmp") cmp.setup({ autoEnableSources = true, experimental = { ghost_text = true }, formatting = { fields = { "kind", "abbr", "menu" } }, mapping = { [""] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }), [""] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }), }, snippet = { expand = function(args) luasnip.lsp_expand(args.body) end }, sources = { { name = "nvim_lsp" }, { name = "emoji" }, { keywordLength = 3, name = "buffer", option = { get_bufnrs = vim.api.nvim_list_bufs } }, { keywordLength = 3, name = "path" }, { keywordLength = 3, name = "luasnip" }, }, window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, }) vim.lsp.inlay_hint.enable(true) local __lspCapabilities = function() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) return capabilities end local __setup = { capabilities = __lspCapabilities() } local __wrapConfig = function(cfg) if cfg == nil then cfg = __setup else cfg = vim.tbl_extend("keep", cfg, __setup) end return cfg end vim.lsp.config("clangd", { cmd = { "clangd" }, filetypes = { "c", "cpp" } }) vim.lsp.enable("clangd") vim.lsp.config("haskell-language-server", { cmd = { "haskell-language-server-wrapper", "--lsp" }, filetypes = { "haskell" } }) vim.lsp.enable("haskell-language-server") vim.lsp.config("lua_ls", { cmd = { "lua-language-server" }, filetypes = { "lua" } }) vim.lsp.enable("lua_ls") vim.lsp.config("nil_ls", { cmd = { "nil" }, filetypes = { "nix" } }) vim.lsp.enable("nil_ls") vim.lsp.config("nixd", { cmd = { "nixd" }, filetypes = { "nix" } }) vim.lsp.enable("nixd") vim.lsp.config("pyright", { cmd = { "pyright" }, filetypes = { "python" } }) vim.lsp.enable("pyright") vim.lsp.config("zls", { cmd = { "zls" }, filetypes = { "zig" } }) vim.lsp.enable("zls") -- https://github.com/catppuccin/nvim/blob/main/lua/catppuccin/palettes/mocha.lua -- https://github.com/Ronxvier/ymir.nvim/blob/main/lua/ymir/palette.lua local colors = { red = "#f38ba8", orange = "#fab387", green = "#a6e3a1", yellow = "#f9e2af", pink = "#f5c2e7", magenta = "#cba6f7", cyan = "#94e2d5", bg = "#11111b", fg = "#cdd6f4", cursorline = "#181825", selection = "#313244", linenr = "#45475a", comment = "#585b70", -- Syntax keyword = "#cba6f7", Function = "#cba6f7", string = "#f9e2af", constant = "#cba6f7", type = "#94e2d5", number = "#fab387", boolean = "#fab387", operator = "#cdd6f4", variable = "#cdd6f4", -- TODO -- UI cursor = "#f5a97f", visual = "#2e3c55", search = "#f5c2e7", statusline = "#1e293b", menu_bg = "#1a2535", menu_sel = "#3b4252", fold = "#3e4a5a", split = "#334155", -- TODO -- Diagnostics diag_error = "#f38ba8", diag_warn = "#fab387", diag_info = "#89dceb", diag_hint = "#b4befe", } -- https://github.com/Ronxvier/ymir.nvim/blob/main/lua/ymir/groups.lua local groups = { Normal = { fg = colors.fg, bg = colors.bg }, NormalFloat = { fg = colors.fg, bg = colors.bg }, Comment = { fg = colors.comment, italic = true }, Constant = { fg = colors.constant }, String = { fg = colors.string }, Character = { fg = colors.string }, Number = { fg = colors.number }, Boolean = { fg = colors.boolean }, Float = { fg = colors.number }, FloatBorder = { fg = colors.number }, Operator = { fg = colors.operator }, Keyword = { fg = colors.keyword }, Keywords = { fg = colors.keyword }, Identifier = { fg = colors.variable }, Function = { fg = colors.Function }, Statement = { fg = colors.keyword }, Conditional = { fg = colors.keyword }, Repeat = { fg = colors.keyword }, Label = { fg = colors.keyword }, Exception = { fg = colors.keyword }, PreProc = { fg = colors.keyword }, Include = { fg = colors.keyword }, Define = { fg = colors.keyword }, Title = { fg = colors.magenta }, Macro = { fg = colors.keyword }, PreCondit = { fg = colors.yellow }, Type = { fg = colors.type, italic = true }, StorageClass = { fg = colors.type, italic = true }, Structure = { fg = colors.type, italic = true }, TypeDef = { fg = colors.type, italic = true }, Special = { fg = colors.keyword, italic = true }, SpecialComment = { fg = colors.comment, italic = true }, Error = { fg = colors.red }, Todo = { fg = colors.yellow, bold = true, italic = true }, Underlined = { fg = colors.cyan, underline = true }, Cursor = { fg = colors.cursor }, CursorLineNr = { fg = colors.fg, bold = true }, SignColumn = { bg = colors.bg }, Conceal = { fg = colors.comment }, -- CursorColumn = { bg = colors.selection}, CursorLine = { bg = colors.selection }, ColorColumn = { bg = colors.selection }, StatusLine = { fg = colors.statusline, bg = colors.black }, StatusLineNC = { fg = colors.comment }, StatusLineTerm = { fg = colors.fg, bg = colors.black }, StatusLineTermNC = { fg = colors.comment }, Directory = { fg = colors.cyan }, DiffAdd = { fg = colors.bg, bg = colors.green }, DiffChange = { fg = colors.orange }, DiffDelete = { fg = colors.red }, DiffText = { fg = colors.comment }, ErrorMsg = { fg = colors.red }, VertSplit = { fg = colors.fg }, WinSeparator = { fg = colors.fg }, Folded = { fg = colors.comment }, FoldColumn = {}, Search = { fg = colors.fg, bg = colors.selection }, IncSearch = { fg = colors.fg, bg = colors.selection }, LineNr = { fg = colors.comment }, MatchParen = { fg = colors.cyan, underline = true }, NonText = { fg = colors.comment }, Pmenu = { fg = colors.fg, bg = colors.bg }, PmenuSel = { fg = colors.bg, bg = colors.fg }, PmenuSbar = { bg = colors.bg }, PmenuThumb = { bg = colors.bg }, Question = { fg = colors.magenta }, QuickFixLine = { fg = colors.bg, bg = colors.yellow }, SpecialKey = { fg = colors.comment }, SpellBad = { fg = colors.red, underline = true }, SpellCap = { fg = colors.yellow }, SpellLocal = { fg = colors.yellow }, SpellRare = { fg = colors.yellow }, TabLine = { fg = colors.comment }, TabLineSel = { fg = colors.fg }, TabLineFill = { bg = colors.bg }, Terminal = { fg = colors.fg, bg = colors.black }, Visual = { bg = colors.visual }, VisualNOS = { fg = colors.visual }, WarningMsg = { fg = colors.yellow }, WildMenu = { fg = colors.black, bg = colors.white }, -- TreeSitter ["@comment"] = { fg = colors.comment, italic = true }, ["@error"] = { fg = colors.red }, ["@punctuation.delimiter"] = { fg = colors.fg }, ["@punctuation.bracket"] = { fg = colors.fg }, ["@punctuation.special"] = { fg = colors.cyan }, ["@constant"] = { fg = colors.constant }, ["@constant.builtin"] = { fg = colors.constant }, ["@symbol"] = { fg = colors.operator }, ["@constant.macro"] = { fg = colors.keyword }, ["@string.regex"] = { fg = colors.string }, ["@string"] = { fg = colors.string }, ["@string.escape"] = { fg = colors.green }, ["@character"] = { fg = colors.string }, ["@number"] = { fg = colors.number }, ["@boolean"] = { fg = colors.boolean }, ["@float"] = { fg = colors.number }, ["@annotation"] = { fg = colors.yellow }, ["@attribute"] = { fg = colors.cyan }, ["@namespace"] = { fg = colors.cyan }, ["@function.builtin"] = { fg = colors.Function }, ["@function"] = { fg = colors.Function }, ["@function.macro"] = { fg = colors.Function }, ["@parameter"] = { fg = colors.number }, ["@parameter.reference"] = { fg = colors.number }, ["@method"] = { fg = colors.number }, ["@field"] = { fg = colors.number }, ["@property"] = { fg = colors.type }, ["@constructor"] = { fg = colors.cyan }, ["@conditional"] = { fg = colors.pink }, ["@repeat"] = { fg = colors.pink }, ["@label"] = { fg = colors.cyan }, ["@keyword"] = { fg = colors.keyword }, ["@keyword.function"] = { fg = colors.Function }, ["@keyword.function.ruby"] = { fg = colors.Function }, --["@keyword.operator"] = { fg = colors.pink }, --["@operator"] = { fg = colors.pink }, ["@exception"] = { fg = colors.magenta }, ["@type"] = { fg = colors.bright_cyan }, ["@type.builtin"] = { fg = colors.cyan, italic = true }, ["@type.qualifier"] = { fg = colors.pink }, ["@structure"] = { fg = colors.magenta }, ["@include"] = { fg = colors.pink }, ["@variable"] = { fg = colors.variable }, ["@variable.builtin"] = { fg = colors.variable }, ["@text"] = { fg = colors.number }, ["@text.strong"] = { fg = colors.number, bold = true }, -- bold ["@text.emphasis"] = { fg = colors.yellow, italic = true }, -- italic ["@text.underline"] = { fg = colors.number }, ["@text.title"] = { fg = colors.pink, bold = true }, -- title ["@text.literal"] = { fg = colors.number }, -- inline code ["@text.uri"] = { fg = colors.yellow, italic = true, underline = true }, -- urls ["@text.reference"] = { fg = colors.number, bold = true }, ["@tag"] = { fg = colors.cyan }, ["@tag.attribute"] = { fg = colors.number }, ["@tag.delimiter"] = { fg = colors.pink }, -- Semantic ["@class"] = { fg = colors.cyan }, ["@struct"] = { fg = colors.cyan }, ["@enum"] = { fg = colors.cyan }, ["@enumMember"] = { fg = colors.magenta }, ["@event"] = { fg = colors.cyan }, ["@interface"] = { fg = colors.cyan }, ["@modifier"] = { fg = colors.cyan }, ["@regexp"] = { fg = colors.yellow }, ["@typeParameter"] = { fg = colors.cyan }, ["@decorator"] = { fg = colors.cyan }, -- LSP Semantic (0.9+) ["@lsp.type.class"] = { fg = colors.type }, ["@lsp.type.enum"] = { fg = colors.type }, ["@lsp.type.decorator"] = { fg = colors.number }, ["@lsp.type.enumMember"] = { fg = colors.type }, ["@lsp.type.function"] = { fg = colors.Function }, ["@lsp.type.interface"] = { fg = colors.keyword }, ["@lsp.type.macro"] = { fg = colors.keyword }, ["@lsp.type.method"] = { fg = colors.keyword }, ["@lsp.type.namespace"] = { fg = colors.keyword }, ["@lsp.type.parameter"] = { fg = colors.keyword }, ["@lsp.type.property"] = { fg = colors.keyword }, ["@lsp.type.struct"] = { fg = colors.type }, ["@lsp.type.type"] = { fg = colors.type }, ["@lsp.type.variable"] = { fg = colors.variable }, -- HTML htmlArg = { fg = colors.orange }, htmlBold = { fg = colors.yellow, bold = true }, htmlEndTag = { fg = colors.cyan }, htmlH1 = { fg = colors.pink }, htmlH2 = { fg = colors.pink }, htmlH3 = { fg = colors.pink }, htmlH4 = { fg = colors.pink }, htmlH5 = { fg = colors.pink }, htmlH6 = { fg = colors.pink }, htmlItalic = { fg = colors.magenta, italic = true }, htmlLink = { fg = colors.magenta, underline = true }, htmlSpecialChar = { fg = colors.yellow }, htmlSpecialTagName = { fg = colors.cyan }, htmlTag = { fg = colors.cyan }, htmlTagN = { fg = colors.cyan }, htmlTagName = { fg = colors.cyan }, htmlTitle = { fg = colors.white }, } for group, setting in pairs(groups) do vim.api.nvim_set_hl(0, group, setting) end -- nixvim stuff do local __nixvim_autogroups = { nixvim_binds_LspAttach = { clear = true }, nixvim_lsp_on_attach = { clear = false } } for group_name, options in pairs(__nixvim_autogroups) do vim.api.nvim_create_augroup(group_name, options) end end do local __nixvim_autocommands = { { callback = function(event) do -- client and bufnr are supplied to the builtin `on_attach` callback, -- so make them available in scope for our global `onAttach` impl local client = vim.lsp.get_client_by_id(event.data.client_id) local bufnr = event.buf require("lsp-format").on_attach(client, bufnr) end end, desc = "Run LSP onAttach", event = "LspAttach", group = "nixvim_lsp_on_attach", }, { callback = function(args) do local __nixvim_binds = {} for i, map in ipairs(__nixvim_binds) do local options = vim.tbl_extend("keep", map.options or {}, { buffer = args.buf }) vim.keymap.set(map.mode, map.key, map.action, options) end end end, desc = "Load keymaps for LspAttach", event = "LspAttach", group = "nixvim_binds_LspAttach", }, { command = ":set guicursor=a:ver90-blinkon0", event = { "VimLeave" } }, } for _, autocmd in ipairs(__nixvim_autocommands) do vim.api.nvim_create_autocmd(autocmd.event, { group = autocmd.group, pattern = autocmd.pattern, buffer = autocmd.buffer, desc = autocmd.desc, callback = autocmd.callback, command = autocmd.command, once = autocmd.once, nested = autocmd.nested, }) end end -- }} -- https://github.com/nvim-lualine/lualine.nvim/blob/master/examples/bubbles.lua local bubbles_theme = { normal = { a = { fg = colors.bg, bg = colors.magenta }, b = { fg = colors.bg, bg = colors.magenta }, c = { fg = colors.bg, bg = colors.bg }, }, insert = { a = { fg = colors.bg, bg = colors.green } }, visual = { a = { fg = colors.bg, bg = colors.cyan } }, replace = { a = { fg = colors.bg, bg = colors.red } }, inactive = { a = { fg = colors.fg, bg = colors.bg }, b = { fg = colors.fg, bg = colors.bg }, c = { fg = colors.fg }, }, } require('lualine').setup { options = { theme = bubbles_theme, component_separators = '', section_separators = { left = '', right = '' }, }, sections = { lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } }, lualine_b = { 'filename', 'branch' }, lualine_c = {}, lualine_x = {}, lualine_y = { 'filetype', 'progress' }, lualine_z = { { 'location', separator = { right = '' }, left_padding = 2 }, }, }, inactive_sections = { lualine_a = { 'filename' }, lualine_b = {}, lualine_c = {}, lualine_x = {}, lualine_y = {}, lualine_z = { 'location' }, }, tabline = {}, extensions = {}, }