-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
288 lines (244 loc) · 8.89 KB
/
init.lua
File metadata and controls
288 lines (244 loc) · 8.89 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
-- init.lua
vim.o.number = true
vim.o.smartcase = true
vim.o.ignorecase = true
vim.o.wrap = false
vim.o.hlsearch = false
vim.o.signcolumn = 'yes'
vim.opt.autoindent = true
vim.opt.smartindent = true
vim.opt.tabstop = 2 -- 1 tab = 2 spaces
vim.opt.shiftwidth = 2 -- indentation rule
vim.opt.formatoptions = 'qnj1' -- q - comment formatting; n - numbered lists; j - remove comment when joining lines; 1 - don't break after one-letter word
vim.opt.expandtab = true -- expand tab to spaces
-- Space as the leader key
vim.g.mapleader = vim.keycode('<Space>')
-- Basic clipboard interaction
vim.keymap.set({'n', 'x'}, 'gy', '"+y', {desc = 'Copy to clipboard'})
vim.keymap.set({'n', 'x'}, 'gp', '"+p', {desc = 'Paste clipboard text'})
-- Command shortcuts
vim.keymap.set('n', '<leader>w', '<cmd>write<cr>', {desc = 'Save file'})
vim.keymap.set('n', '<leader>q', '<cmd>quitall<cr>', {desc = 'Exit vim'})
-- escape is missing from IPad keyboards so '§' is used instead
vim.keymap.set('i', '§', '<ESC>', {})
-- buffer navigation
vim.keymap.set('n', '<leader><Right>', '<cmd>bn<cr>', {})
vim.keymap.set('n', '<leader><Left>', '<cmd>bp<cr>', {})
vim.keymap.set('n', '<leader><Down>', '<cmd>bd<cr>', {})
vim.keymap.set('n', '<leader><Up>', '<cmd>enew<cr>i', {})
-- clear highlights
vim.keymap.set('n', '<leader>n', '<cmd>noh<cr>', {})
vim.keymap.set('n', '<leader>jq', '<cmd>%!jq -S .<cr>', {})
vim.keymap.set('n', '<leader>jc', '<cmd>%!jq -c .<cr>', {})
-- yank word
vim.keymap.set('n', '<leader>y', 'viwy', {})
-- simple surround mappings
vim.keymap.set('n', '<leader>sv', 'viwxi${}<ESC>P', {}) -- variable
vim.keymap.set('n', '<leader>sV', 'viwxi"${}"<ESC>hP', {}) -- variable quoted
vim.keymap.set('v', '<leader>sq', "xi''<ESC>P", {}) -- quotes
vim.keymap.set('v', '<leader>sd', 'xi""<ESC>P', {}) -- double quotes
vim.keymap.set('v', '<leader>sb', 'xi()<ESC>P', {}) -- brackets
vim.keymap.set('v', '<leader>ss', 'xi{}<ESC>P', {}) -- squiglies
vim.keymap.set('v', '<leader>sa', 'xi[]<ESC>P', {}) -- array
vim.keymap.set('v', '<leader>sv', 'xi${}<ESC>P', {}) -- variable
vim.keymap.set('v', '<leader>sV', 'xi"${}"<ESC>hP', {}) -- variable quoted
vim.keymap.set('v', '<leader>sc', 'xi$()<ESC>P', {}) -- capture
-- function
vim.keymap.set('n', '<leader>ss', 'A {<cr>}<ESC>ko', {})
-- ------------------
local ok, MiniDeps = pcall(require, 'mini.deps')
if not ok then
vim.notify('[WARN] mini.deps module not found', vim.log.levels.WARN)
return
end
MiniDeps.setup({})
require('mini.snippets').setup({})
require('mini.completion').setup({})
-- require('mini.cursorword').setup({}) -- ugly
-- require('mini.files').setup({})
-- vim.keymap.set('n', '<leader>e', '<cmd>lua MiniFiles.open()<cr>', {desc = 'File explorer'})
require('mini.pick').setup({})
vim.keymap.set('n', '<leader><space>', '<cmd>Pick buffers<cr>', {desc = 'Search open files'})
vim.keymap.set('n', '<leader>ff', '<cmd>Pick files<cr>', {desc = 'Search all files'})
vim.keymap.set('n', '<leader>fh', '<cmd>Pick help<cr>', {desc = 'Search help tags'})
-- airline
MiniDeps.add('vim-airline/vim-airline')
MiniDeps.add('vim-airline/vim-airline-themes')
-- lastplace
MiniDeps.add('ethanholz/nvim-lastplace')
require'nvim-lastplace'.setup{}
-- tokyonight
MiniDeps.add('folke/tokyonight.nvim')
require("tokyonight").setup({
on_colors = function (colors)
colors.fg_gutter = "#b2b8cf"
end
})
vim.cmd.colorscheme('tokyonight')
-- treesitter
MiniDeps.add('nvim-treesitter/nvim-treesitter')
require('nvim-treesitter').setup({
install_dir = vim.fn.stdpath('data') .. '/site',
ensure_installed = { 'lua', 'vimdoc', 'nushell'},
highlight = { enable = true },
})
-- toggleterm
MiniDeps.add('akinsho/toggleterm.nvim')
require('toggleterm').setup {
size = 20,
open_mapping = [[<c-\>]],
hide_numbers = true,
shade_filetypes = {},
shade_terminals = true,
shading_factor = 2,
start_in_insert = true,
insert_mappings = true,
persist_size = true,
direction = "float",
close_on_exit = true,
shell = vim.o.shell,
float_opts = {
border = "curved",
winblend = 0,
highlights = {
border = "Normal",
background = "Normal",
},
},
}
-- oil
MiniDeps.add('stevearc/oil.nvim')
require("oil").setup({
-- Id is automatically added at the beginning, and name at the end
-- See :help oil-columns
columns = {
-- "icon",
-- "permissions",
-- "size",
-- "mtime",
},
-- Buffer-local options to use for oil buffers
buf_options = {
buflisted = false,
bufhidden = "hide",
},
-- Window-local options to use for oil buffers
win_options = {
wrap = false,
signcolumn = "no",
cursorcolumn = false,
foldcolumn = "0",
spell = false,
list = false,
conceallevel = 3,
concealcursor = "n",
},
-- Oil will take over directory buffers (e.g. `vim .` or `:e src/`
default_file_explorer = true,
-- Restore window options to previous values when leaving an oil buffer
restore_win_options = true,
-- Skip the confirmation popup for simple operations
skip_confirm_for_simple_edits = false,
-- Deleted files will be removed with the trash_command (below).
delete_to_trash = false,
-- Change this to customize the command used when deleting to trash
trash_command = "trash-put",
-- Selecting a new/moved/renamed file or directory will prompt you to save changes first
prompt_save_on_select_new_entry = true,
-- Keymaps in oil buffer. Can be any value that `vim.keymap.set` accepts OR a table of keymap
-- options with a `callback` (e.g. { callback = function() ... end, desc = "", nowait = true })
-- Additionally, if it is a string that matches "actions.<name>",
-- it will use the mapping at require("oil.actions").<name>
-- Set to `false` to remove a keymap
-- See :help oil-actions for a list of all available actions
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = "actions.select_vsplit",
["<C-h>"] = "actions.select_split",
["<C-t>"] = "actions.select_tab",
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = "actions.refresh",
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = "actions.tcd",
["g."] = "actions.toggle_hidden",
},
-- Set to false to disable all of the above keymaps
use_default_keymaps = true,
view_options = {
-- Show files and directories that start with "."
show_hidden = true,
-- This function defines what is considered a "hidden" file
is_hidden_file = function(name, bufnr)
return vim.startswith(name, ".")
end,
-- This function defines what will never be shown, even when `show_hidden` is set
is_always_hidden = function(name, bufnr)
return false
end,
},
-- Configuration for the floating window in oil.open_float
float = {
-- Padding around the floating window
padding = 2,
max_width = 0,
max_height = 0,
border = "rounded",
win_options = {
winblend = 10,
},
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
override = function(conf)
return conf
end,
},
-- Configuration for the actions floating preview window
preview = {
-- Width dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_width and max_width can be a single value or a list of mixed integer/float types.
-- max_width = {100, 0.8} means "the lesser of 100 columns or 80% of total"
max_width = 0.9,
-- min_width = {40, 0.4} means "the greater of 40 columns or 40% of total"
min_width = { 40, 0.4 },
-- optionally define an integer/float for the exact width of the preview window
width = nil,
-- Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
-- min_height and max_height can be a single value or a list of mixed integer/float types.
-- max_height = {80, 0.9} means "the lesser of 80 columns or 90% of total"
max_height = 0.9,
-- min_height = {5, 0.1} means "the greater of 5 columns or 10% of total"
min_height = { 5, 0.1 },
-- optionally define an integer/float for the exact height of the preview window
height = nil,
border = "rounded",
win_options = {
winblend = 0,
},
},
-- Configuration for the floating progress window
progress = {
max_width = 0.9,
min_width = { 40, 0.4 },
width = nil,
max_height = { 10, 0.9 },
min_height = { 5, 0.1 },
height = nil,
border = "rounded",
minimized_border = "none",
win_options = {
winblend = 0,
},
},
})
vim.keymap.set("n", "-", require('oil').open, { desc = "Open current directory" })
-- lsp-config
-- List of compatible language servers is here:
-- https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
MiniDeps.add('neovim/nvim-lspconfig')
-- vim.lsp.enable({'gopls', 'rust_analyzer'}) -- broken
vim.lsp.enable({'nushell'})
vim.lsp.enable({'python'})