-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
94 lines (73 loc) · 2.35 KB
/
Copy pathinit.lua
File metadata and controls
94 lines (73 loc) · 2.35 KB
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
vim.g.maplocalleader = " "
vim.g.mapleader = " "
-- Fix Treesitter parser path
vim.opt.rtp:prepend(vim.fn.stdpath("data") .. "/site")
vim.filetype.add({
extension = {
ptx = "xml",
},
})
-- Load plugins
require("config.lazy")
-- Load remaps
require("keymaps")
-- Load lspconfig
-- require("config.lsp")
-- Line numbers and relative lines
vim.opt.number = true
vim.opt.relativenumber = true
-- Make indentation work
vim.o.expandtab = true
vim.o.shiftwidth = 2
vim.o.tabstop = 2
vim.o.smartindent = true
-- Insert cursor: block
vim.opt.guicursor = ""
-- Set colorscheme
vim.cmd("colorscheme catppuccin")
-- Scrolloff
vim.opt.scrolloff = 8
vim.opt.showmode = false
-- Format text when window size is changed -----------------------------------
vim.api.nvim_create_augroup("MyWindowResizing", { clear = true })
vim.api.nvim_create_autocmd("VimResized", {
group = "MyWindowResizing",
callback = function()
local ft = vim.bo.filetype
if ft == "text" or ft == "markdown" or ft == "gitcommit" then
local width = math.floor(0.8*vim.api.nvim_win_get_width(0))
vim.opt_local.textwidth = width
vim.cmd("normal! ggVGgq")
end
end,
desc = "Automatically adjust textwidth and reformat on window resize",
})
------------------------------------------------------------------------------
-- Automatically write when needed
vim.o.autowrite = true
-- Automatically save all buffers when leaving Neovim
vim.api.nvim_create_autocmd("FocusLost", {
pattern = "*",
command = "wa",
})
-- Disable Kitty Keyboard Protocol (breaks keyd-synthesized <Esc> in Konsole)
--
-- Nvim only enables the protocol *after* the terminal replies to its startup
-- query, so hooking UIEnter alone is a race: when the reply lands late, nvim
-- pushes the protocol back on and <Esc> stops working. TermResponse fires on
-- that reply, and the deferred pop is guaranteed to land after nvim's push.
-- Note: nvim_ui_send writes through nvim's own output buffer; io.stdout
-- bypasses it and can be reordered against nvim's own sequences.
local function disable_kitty_keyboard()
pcall(vim.api.nvim_ui_send, "\27[<u")
end
vim.api.nvim_create_autocmd("UIEnter", {
once = true,
callback = disable_kitty_keyboard,
})
vim.api.nvim_create_autocmd("TermResponse", {
callback = function()
vim.schedule(disable_kitty_keyboard)
vim.defer_fn(disable_kitty_keyboard, 50)
end,
})