forked from hardhackerlabs/oh-my-nvim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.lua
74 lines (59 loc) · 2.34 KB
/
settings.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
local keys = require("custom_keys")
local opts = require("custom_opts")
local map = vim.keymap.set
local option = {noremap = true, silent = true }
map('n', keys.jump_left_window, '<C-W>h', option)
map('n', keys.jump_down_window, '<C-W>j', option)
map('n', keys.jump_up_window, '<C-W>k', option)
map('n', keys.jump_right_window, '<C-W>l', option)
-- Supported by bufdelete
-- vim.cmd([[cnoreabbrev q Bdelete]])
-- Supported by bufferline
map('n', keys.pick_tab, ':BufferLinePick<CR>', option)
-- Supported by nvim-tree
map('n', keys.file_explorer, ':Neotree position=left source=filesystem action=show toggle=true<CR>', option)
map('n', keys.git_status, ':Neotree position=float source=git_status action=show toggle=true<CR>', option)
-- Supported by aerial
map('n', keys.outline, ':AerialToggle! right<CR>', option)
-- Supported by diffview
map('n', keys.diff_open, ':DiffviewOpen<CR>', option)
map('n', keys.diff_close, ':DiffviewClose<CR>', option)
-- Supported by floaterm
map('n', keys.terminal, ':ToggleTerm<CR><C-\\><C-n>a', option)
map('t', keys.terminal, '<C-\\><C-n>:ToggleTerm<CR>', option)
-- Supported by nvim-session-manager
map('n', keys.switch_session, ':SessionManager load_session<CR>', option)
-- Function to set up the save shortcut
--
local function setup_save_shortcut()
local is_mac = vim.fn.has("mac") == 1
local is_linux = vim.fn.has("unix") == 1 and not is_mac
local is_windows = vim.fn.has("win32") == 1
-- Define key mappings
local map = function(mode, lhs, rhs)
vim.api.nvim_set_keymap(mode, lhs, rhs, {noremap=true})
end
if is_mac then
map('n', '<D-s>', ':w<CR>')
map('v', '<D-s>', ':w<CR>')
map('i', '<D-s>', '<Esc>:w<CR>a')
elseif is_linux then
map('n', '<C-s>', ':w<CR>')
map('v', '<C-s>', ':w<CR>')
map('i', '<C-s>', '<Esc>:w<CR>a')
elseif is_windows then
map('n', '<C-s>', ':w<CR>')
map('v', '<C-s>', ':w<CR>')
map('i', '<C-s>', '<Esc>:w<CR>a')
end
end
setup_save_shortcut()
-- Setup autocmd
local hardhacker_config_group = vim.api.nvim_create_augroup('HardHackerConfigGroup', {})
vim.api.nvim_create_autocmd({ 'User' }, {
pattern = "SessionLoadPost",
group = hardhacker_config_group,
callback = function()
vim.api.nvim_command("Neotree position=left source=filesystem action=show toggle=true")
end,
})