aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/init.lua
blob: 7df64c2c51d6847a1109fc384b704c729801fc3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---@diagnostic disable: undefined-global
vim.o.termguicolors = true
vim.o.relativenumber = true
vim.o.number = true
vim.o.signcolumn = "no"
vim.o.cc = "80"
vim.o.splitright = true
vim.o.splitbelow = true
vim.o.ignorecase = true
vim.o.winborder="single"
vim.o.completeopt = "menu,menuone,noselect"

vim.o.mouse = ""
vim.o.guicursor = "n-c-sm-ve:block-Cursor,i-ci:block-Cursor_i,v:block-Cursor_v"

vim.o.listchars = "tab:> ,trail:."
vim.o.list = true

vim.o.tabstop = 8
vim.o.shiftwidth = 8
vim.o.expandtab = true

vim.o.undofile = true
vim.o.backup = false
vim.o.writebackup = false
vim.o.swapfile = false

vim.opt.cinoptions:append(":0,N-s,E-s,(s,Ws")

vim.g.mapleader = " "
vim.g.netrw_banner = 0

vim.pack.add({
  "https://codeberg.org/comfysage/artio.nvim",
  "https://github.com/tpope/vim-fugitive",

  "https://git.iamcheeseman.net/mooncheese.nvim.git",
})

for _, plugin in ipairs(vim.pack.get()) do
  if not plugin.active then
    vim.pack.del({plugin.path:match(".*/(.*)$")})
  end
end

require("artio").setup({
        opts = {
                promptprefix = ">",
                pointer = ">",
        },
})

vim.keymap.set("n", "<leader>f", function()
  require("artio.builtins").files({
    findprg = [[ find . -type f -iregex '.*$*.*' -not -path '*/.*' ]]
  })
end)
vim.keymap.set("v", "p", '"_dP', opts)
vim.keymap.set("n", "<leader>s", ":SwapFile<CR>")

-- Switch between semantically related files easily :)
local exts = {{"c", "h"}, {"cc", "hh"}, {"cpp", "hpp"}, {"frag", "vert"}}
vim.api.nvim_create_user_command("SwapFile", 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.api.nvim_create_autocmd("LspAttach", {
  callback = function(ev)
    local opts = {silent=true, buffer=ev.buf}
    vim.keymap.set("n", "gD", function() vim.lsp.buf.declaration() end, opts)
    vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
  end,
})

vim.lsp.enable({"lua_ls", "clangd"})
vim.diagnostic.config({
  virtual_text = true,
  severity_sort = true,
})

vim.cmd.colorscheme("mooncheese")
vim.api.nvim_set_hl(0, "Cursor_i", {bg="#00FFFF"})
vim.api.nvim_set_hl(0, "Cursor_v", {bg="#FF00FF"})

require("vim._core.ui2").enable({enable = true})