-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
108 lines (94 loc) · 2.57 KB
/
init.lua
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
96
97
98
99
100
101
102
103
104
105
106
107
108
require "nacro.options"
require "nacro.keymaps"
local command = require "nacro.utils.command"
local api = vim.api
local fn = vim.fn
local nlazy = require "nacro.lazy"
nlazy.bootstrap()
nlazy.setup()
command("LuaHas", function(keys)
vim.notify(vim.inspect(pcall(require, keys.args)))
end, {
nargs = 1,
})
command("RemoveTrailingWhitespace", [[silent! %substitute/\s\+$//]], { nargs = 0 })
command("W", "w")
command("Q", "q")
command("Wq", "wq")
command("WQ", "wq")
api.nvim_create_autocmd("TextYankPost", {
group = api.nvim_create_augroup("highlight_yank", {}),
callback = function()
vim.highlight.on_yank { higroup = "Visual", timeout = 200 }
end,
})
-- Jump to the last known cursor position
api.nvim_create_autocmd("BufReadPost", {
callback = function()
local pos = vim.fn.line "'\""
if pos > 0 and pos <= vim.api.nvim_buf_line_count(0) then
vim.cmd 'normal g`"'
end
end,
})
command("RenameBuffer", function(arg)
local name
if arg and #arg > 0 then
name = arg
else
name = fn.input "Buffer name: "
if not name or #name == 0 then
return
end
end
api.nvim_buf_set_name(0, name)
end, {
nargs = "?",
})
require("nacro.matchparen").setup()
require("nacro.terminal").setup()
require("nacro.howdoi").setup()
-- require("nacro.clipboard_image").setup()
require("nacro.neovide").setup_if_neovide()
require("nacro.buffer").setup()
command("TimestampToDatetime", function(a)
a = a.args
print(os.date("%Y-%m-%d %H:%M:%S", a / 1000) .. "." .. a % 1000)
end, {
nargs = 1,
})
vim.diagnostic.config {
virtual_text = {
severity = { min = vim.diagnostic.severity.ERROR },
},
underline = {
severity = { min = vim.diagnostic.severity.WARN },
},
}
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition { reuse_win = true }
end)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.hover)
vim.keymap.set("n", "<C-j>", vim.diagnostic.open_float)
vim.keymap.set({ "n", "v" }, "<leader>a", vim.lsp.buf.code_action)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_next {
severity = { min = vim.diagnostic.severity.WARN },
}
end)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next {
severity = { min = vim.diagnostic.severity.WARN },
}
end)
vim.keymap.set({ "i", "n" }, "<C-q>", vim.lsp.buf.signature_help)
vim.keymap.set("n", "gD", function()
vim.lsp.buf.type_definition { reuse_win = true }
end)
vim.keymap.set({ "n", "v" }, "gl", vim.lsp.buf.format, { desc = "LSP format buffer" })
vim.keymap.set(
"n",
"<C-w>N",
require("nacro.kitty").buffer_to_new_window,
{ desc = "Open buffer in a new kitty window" }
)