-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
92 lines (73 loc) · 2.8 KB
/
Copy pathinit.lua
File metadata and controls
92 lines (73 loc) · 2.8 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
-- split right...
vim.opt.splitright = true
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
vim.opt.number = true
vim.opt.relativenumber = false
-- Enable syntax highlighting (enabled by default in Lua, but good to know)
vim.cmd("syntax on")
-- Enable mouse mode
vim.opt.mouse = "a"
-- Set tab settings
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
-- Enable true color support
vim.opt.termguicolors = true
-- Use system clipboard
vim.opt.clipboard = "unnamedplus"
-- Suppress deprecation warnings (lspconfig migration to vim.lsp.config)
vim.deprecate = function() end
-- Treesitter compatibility shim for older plugins
vim.treesitter.language = vim.treesitter.language or {}
vim.treesitter.language.ft_to_lang = vim.treesitter.language.ft_to_lang
or vim.treesitter.language.get_lang
or function(ft) return ft end
-- Auto-reload files changed externally
vim.opt.autoread = true
vim.api.nvim_create_autocmd({ "FocusGained", "BufEnter", "CursorHold", "CursorHoldI" }, {
command = "if mode() != 'c' | checktime | endif",
pattern = { "*" },
})
require("config.lazy")
vim.keymap.set("n", "<leader>e", "<Cmd>Neotree reveal<CR>")
vim.keymap.set("n", "<leader>E", "<Cmd>Neotree toggle<CR>")
-- colorscheme set in lua/plugins/colorscheme.lua
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]])
--
-- vim.keymap.set("n", "<leader>ts", [[<C-w>s <C-w>j <cmd>terminal<CR>]])
-- open terminal in a split window, if one already exists, switch focus to it
-- if currently in terminal, switch back to the previous window
local previous_win = nil
vim.keymap.set('n', '<C-`>', function()
local term_bufnr = nil
for _, win in ipairs(vim.api.nvim_list_wins()) do
local buf = vim.api.nvim_win_get_buf(win)
if vim.bo[buf].buftype == 'terminal' then
term_bufnr = buf
if vim.api.nvim_get_current_win() == win then
-- If already in terminal, switch back to the previous window
if previous_win and vim.api.nvim_win_is_valid(previous_win) then
vim.api.nvim_set_current_win(previous_win)
end
return
else
-- Save the current window before switching to the terminal
previous_win = vim.api.nvim_get_current_win()
vim.api.nvim_set_current_win(win)
return
end
end
end
-- If no terminal is found, open one and save the current window
if not term_bufnr then
previous_win = vim.api.nvim_get_current_win()
vim.cmd('botright split | resize 15% | terminal')
vim.cmd('startinsert')
end
end, { noremap = true, silent = true })
-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#e3d4d3", fg = "#4a394a" })
vim.api.nvim_set_hl(0, "NormalFloat", { link = "Normal" })
vim.api.nvim_set_hl(0, "FloatBorder", { link = "Normal" })