grace/dots

dotfiles/nix configs

git clone https://git.gae.moe/grace/dots

Grace Yoderhx and vcs changesddf0c79

idk
3.9 KiB159 linesraw
1--
2-- nvim init script by grace
3--
4
5-- Get hostname
6local handle = io.popen("hostname")
7local hostname = handle:read("*a") or ""
8handle:close()
9hostname = hostname:gsub("%s+", "")
10vim.g.hostname = hostname
11if string.match(hostname, "cs.purdue.edu") then
12  vim.g.is_purdue = true
13else
14  vim.g.is_purdue = false
15end
16
17-- add required things to path
18if vim.g.is_purdue then
19  vim.env.PATH = vim.env.PATH .. ':' .. os.getenv("HOME") .. '/clangd/bin:/u/riker/u98/cs240/bin'
20end
21
22require("plugins")
23require("native-lsp")
24require("diagnostics")
25require("remap")
26
27
28if vim.g.is_purdue then
29  require("westwood-lint")
30end
31
32require("standard-lint")
33
34vim.cmd("source ~/.vim/settings.vim")
35
36vim.api.nvim_create_autocmd("BufWritePre", {
37  pattern = "*",
38  callback = function()
39    local save = vim.fn.winsaveview()
40    vim.cmd([[%s/\s\+$//e]])
41    vim.fn.winrestview(save)
42  end,
43})
44
45
46-- File IO can be slow and this might help idk
47if vim.g.is_purdue then
48  vim.cmd("set noundofile") -- i forgor how to do this in lua so i didnt
49end
50
51--
52-- vim.opt.spell = true
53-- vim.opt.spelllang = "en_us"
54--
55
56vim.api.nvim_create_autocmd("FileType", {
57  pattern = "markdown",
58  callback = function()
59    vim.opt_local.textwidth = 80
60    vim.opt_local.formatoptions = "atcqjnl"
61    vim.opt_local.wrap = true
62    vim.opt_local.linebreak = true
63
64    -- Show column guide
65    vim.opt_local.colorcolumn = "80"
66  end,
67})
68
69-- Typst configuration
70vim.api.nvim_create_autocmd("FileType", {
71  pattern = "typst",
72  callback = function()
73    -- Line wrapping settings
74    vim.opt_local.textwidth = 80
75    vim.opt_local.formatoptions = "tcqjnl"
76    vim.opt_local.wrap = true
77    vim.opt_local.linebreak = true
78    -- Show column guide
79    vim.opt_local.colorcolumn = "80"
80
81    -- Toggle 'a' in formatoptions
82    vim.keymap.set("n", "<leader>a", function()
83      local fo = vim.opt_local.formatoptions:get()
84      if fo.a then
85        vim.opt_local.formatoptions:remove("a")
86        print("Auto-formatting disabled")
87      else
88        vim.opt_local.formatoptions:append("a")
89        print("Auto-formatting enabled")
90      end
91    end, { buffer = true, desc = "Toggle auto-formatting" })
92  end,
93})
94-- Setup formatting on LSP attach
95-- vim.api.nvim_create_autocmd("LspAttach", {
96--   callback = function(args)
97--     local client = vim.lsp.get_client_by_id(args.data.client_id)
98--
99--     if client and client.supports_method("textDocument/formatting") then
100--       vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI" }, {
101--         buffer = args.buf,
102--         callback = function()
103--           vim.lsp.buf.format({
104--             async = true,
105--             bufnr = args.buf,
106--           })
107--         end,
108--       })
109--     end
110--   end,
111-- })
112
113vim.api.nvim_create_autocmd("TermOpen", {
114  pattern = "*",
115  callback = function()
116    vim.opt_local.spell = false
117  end,
118})
119
120vim.o.clipboard = "unnamedplus"
121
122-- vim.g.clipboard = {
123--   name = "OSC 52",
124--   copy = {
125--     ["+"] = require("vim.ui.clipboard.osc52").copy("+"),
126--     ["*"] = require("vim.ui.clipboard.osc52").copy("*"),
127--   },
128--   paste = {
129--     ["+"] = require("vim.ui.clipboard.osc52").paste("+"),
130--     ["*"] = require("vim.ui.clipboard.osc52").paste("*"),
131--   },
132-- }
133vim.g.clipboard = "osc52"
134vim.keymap.set("n", "p", '"+p')
135vim.keymap.set("n", "P", '"+P')
136
137
138-- stupid hacky workaround to make it so i can paste from tmux with OSC52
139-- https://github.com/neovim/neovim/discussions/29350#discussioncomment-10299517
140-- tracking issue about tmux behavior: https://github.com/tmux/tmux/issues/4275
141if vim.env.TMUX ~= nil then
142  local copy = { 'tmux', 'load-buffer', '-w', '-' }
143  local paste = { 'bash', '-c', 'tmux refresh-client -l && sleep 0.05 && tmux save-buffer -' }
144  vim.g.clipboard = {
145    name = 'tmux',
146    copy = {
147      ['+'] = copy,
148      ['*'] = copy,
149    },
150    paste = {
151      ['+'] = paste,
152      ['*'] = paste,
153    },
154    cache_enabled = 0,
155  }
156end
157
158-- https://simondalvai.org/blog/godot-neovim/
159require("godot")