---@diagnostic disable: undefined-global local ns = vim.api.nvim_create_namespace("mine") vim.o.termguicolors = true vim.o.relativenumber = true vim.o.number = true vim.o.cc = "80" vim.o.swapfile = false vim.o.splitright = true vim.o.splitbelow = true vim.o.winborder = "bold" vim.o.signcolumn = "yes" vim.o.guicursor = "n-v:block,i-c:ver25,r-cr:hor100,i-r-c:blinkon100,i-r-c:blinkoff100,n-v:blinkon0" vim.o.tabstop = 2 vim.o.shiftwidth = 0 vim.o.expandtab = true vim.o.completeopt = "menu,menuone,noselect" vim.g.mapleader = " " vim.g.qs_highlight_on_keys = {"f", "F", "t", "T"} vim.pack.add({ {src="https://github.com/ibhagwan/fzf-lua"}, {src="https://github.com/williamboman/mason.nvim"}, {src="https://github.com/neovim/nvim-lspconfig"}, {src="https://github.com/nvim-treesitter/nvim-treesitter"}, {src="https://github.com/unblevable/quick-scope"}, }) require("mason").setup({}) require("fzf-lua").setup(require("fzf-lua.profiles.telescope")) require("nvim-treesitter.configs").setup( {ensure_installed = {"lua", "c"}, highlight = {enable=true} }) -- Switch between semantically related files easily :) local exts = {{"c", "h"}, {"cc", "hh"}, {"frag", "vert"}} vim.keymap.set("n", "s", function() local bufpath = vim.api.nvim_buf_get_name(0) for _, pair in ipairs(exts) do for i, ext in ipairs(pair) do if bufpath:match("%." .. ext .. "$") then local other = pair[i % #pair + 1] vim.cmd("e " .. bufpath:gsub("%." .. ext .. "$", "." .. other)) return end end end print("no files to swap to") end, {}) vim.keymap.set("n", "e", ":Ex", {}) -- I'm constantly hitting this and I hate it vim.keymap.set("n", "", "", {}) vim.keymap.set("n", "", function() FzfLua.files({}) end, {}) vim.keymap.set("n", "", function() FzfLua.grep() end, {}) vim.keymap.set("n", "gf", ":vert wincmd f", {silent=true}) vim.keymap.set("n", "b", ":ToScratch", {silent=true}) -- open up the current buffer in a scratch buffer vim.api.nvim_create_user_command("ToScratch", function() local linec = vim.api.nvim_buf_line_count(0) local lines = vim.api.nvim_buf_get_lines(0, 0, linec, false) local buf = vim.api.nvim_create_buf(false, true) vim.api.nvim_set_option_value( "filetype", vim.api.nvim_get_option_value("filetype", {buf=0}), {buf=buf}) vim.api.nvim_buf_set_lines(buf, 0, linec, false, lines) vim.api.nvim_open_win(buf, false, {split="below", win=0}) end, {nargs=0}) vim.lsp.enable({"lua_ls", "clangd"}) vim.api.nvim_create_autocmd("LspAttach", { callback = function(ev) local client = vim.lsp.get_client_by_id(ev.data.client_id) local chars = {} for i = 32, 126 do table.insert(chars, string.char(i)) end client.server_capabilities.completionProvider.triggerCharacters = chars if client:supports_method("textDocument/completion") then vim.lsp.completion.enable(true, client.id, ev.buf, {autotrigger=true}) end end, }) vim.diagnostic.config({virtual_text=true, severity_sort=true}) vim.cmd.colorscheme("mine") vim.api.nvim_set_hl(0, "Normal", {bg="none"}) vim.api.nvim_set_hl(0, "QuickScopePrimary", {fg="#FFFFFF", bg="#1166F3", underline=true}) vim.api.nvim_set_hl(0, "QuickScopeSecondary", {fg="none", bg="#333333", underline=true})