Mon, 13 Mar 2023 15:45:24 -0500
remove standardrb glue now that mason-lspconfig is updated
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
1 | local autocmd = require("config.util").autocmd |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2 | local cmd = vim.cmd |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3 | local fn = vim.fn |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
4 | |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
5 | local g = vim.api.nvim_create_augroup("vimrc", { clear = true }) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
6 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
7 | -- >> neovim specific |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
8 | -- Always start terminals in insert/terminal mode |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
9 | autocmd(g, "TermOpen", "*", cmd.startinsert) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
10 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
11 | -- neovim's autoread doesn't do this by default. |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
12 | autocmd(g, "FocusGained", "*", cmd.checktime) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
13 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
14 | -- >> autowriteall improvment |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
15 | -- Stopinsert on leave, or autowriteall doesn't work. |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
16 | autocmd(g, { "WinLeave", "FocusLost" }, "*", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
17 | if not fn.pumvisible() then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
18 | fn.stopinsert() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
19 | end |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
20 | end) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
21 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
22 | -- write all on leave |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
23 | autocmd(g, "FocusLost", "*", cmd.wa) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
24 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
25 | -- >> auto mkpath on write |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
26 | autocmd(g, "BufWritePre", "*", { |
1076
15007f695dfb
clean up unused vim fns
Meredith Howard <mhoward@roomag.org>
parents:
1075
diff
changeset
|
27 | callback = function(ctx) |
15007f695dfb
clean up unused vim fns
Meredith Howard <mhoward@roomag.org>
parents:
1075
diff
changeset
|
28 | if vim.bo[ctx.buf].buftype == "" and not string.match(ctx.file, "^[%w]+:") then |
15007f695dfb
clean up unused vim fns
Meredith Howard <mhoward@roomag.org>
parents:
1075
diff
changeset
|
29 | fn.mkdir(fn.fnamemodify(ctx.file, ":p:h"), "p") |
15007f695dfb
clean up unused vim fns
Meredith Howard <mhoward@roomag.org>
parents:
1075
diff
changeset
|
30 | end |
15007f695dfb
clean up unused vim fns
Meredith Howard <mhoward@roomag.org>
parents:
1075
diff
changeset
|
31 | end, |
15007f695dfb
clean up unused vim fns
Meredith Howard <mhoward@roomag.org>
parents:
1075
diff
changeset
|
32 | }) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
33 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
34 | -- >> auto session ? |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
35 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
36 | -- >> jump to last position on open |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
37 | autocmd(g, "BufReadPost", "*", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
38 | local ft = vim.bo.filetype |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
39 | if ft == "mail" or string.match(ft, "^git") or string.match(ft, "^hg") then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
40 | return "" |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
41 | end |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
42 | |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
43 | local lastpos = fn.line([['"]]) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
44 | if lastpos >= 1 and lastpos <= fn.line("$") then |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
45 | vim.cmd([[normal! g`"]]) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
46 | end |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
47 | end) |
1075
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
48 | |
3b88450bda15
port custom autocmds to lua
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
49 | -- >> simple highlight conflict markers |
1078
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
50 | autocmd(g, "BufReadPost", "*", function() |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
51 | fn.matchadd("Error", [[\m^\([<>|]\)\{7} \@=\|^=\{7}$]]) |
aa4c1aa529a5
Start porting custom commands to lua
Meredith Howard <mhoward@roomag.org>
parents:
1077
diff
changeset
|
52 | end) |