-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
265 lines (237 loc) · 9.26 KB
/
Copy pathinit.lua
File metadata and controls
265 lines (237 loc) · 9.26 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
-- Show numbers and relative numbers
vim.opt.number = true
vim.opt.relativenumber = true
-- Ignore case when searching in lowercase and do not ignore when searching
-- witch capital cases.
vim.opt.ignorecase = true
vim.opt.smartcase = true
-- Use system clipboard
vim.schedule(function()
vim.opt.clipboard = 'unnamedplus'
end)
-- Prefered colorscheme, wildcharm and desert are cool two
-- vim.cmd.colorscheme 'lunaperche'
-- vim.cmd.colorscheme 'wildcharm'
-- vim.cmd.colorscheme 'desert'
-- Show the cursorline
vim.opt.cursorline = true
-- Set list mode to show tabs and spaces
vim.opt.list = true
-- Minimal number of screen lines
vim.opt.scrolloff = 8
vim.opt.sidescrolloff = 8
-- Configure how new splits should be opened
vim.opt.splitright = true
vim.opt.splitbelow = true
-- No wrap
vim.opt.wrap = false
-- Linebreak
vim.opt.linebreak = true
-- Breakindent
vim.opt.breakindent = true
-- Set <Space> as the leader key
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '
-- Buffer list
vim.keymap.set('n', '<Leader>bl', '<Cmd>:buffers<CR>')
-- Buffer delete
vim.keymap.set('n', '<Leader>bd', '<Cmd>:bdelete<CR>')
-- Open quickfix
vim.keymap.set('n', '<Leader>co', '<Cmd>:copen<CR>')
-- Open locationlist
vim.keymap.set('n', '<Leader>lo', '<Cmd>:lopen<CR>')
-- Clear highlights by pressing <Esc> key
vim.keymap.set('n', '<Esc>', '<Cmd>:nohlsearch<CR>')
-- Diagnostic quickfix show
vim.keymap.set('n', '<Leader>ds', vim.diagnostic.open_float)
-- Toggle wrap
vim.keymap.set('n', '<Leader>tw', '<Cmd>:set wrap!<CR>')
-- Toggle relative numbers
vim.keymap.set('n', '<Leader>tl', '<Cmd>:set rnu!<CR>')
-- Grep
vim.keymap.set('n', '<Leader>lg', ":lexpr system('grep -rin '''' ') | lopen")
vim.keymap.set('n', '<Leader>cg', ":cexpr system('grep -rin '''' ') | copen")
-- Find
vim.keymap.set('n', '<Leader>lf', ":lexpr system('find -iname '''' | awk ''{ print $0 \":1:*\" }''') | lopen")
vim.keymap.set('n', '<Leader>cf', ":cexpr system('find -iname '''' | awk ''{ print $0 \":1:*\" }''') | copen")
-- Git status
vim.keymap.set('n', '<Leader>ls', ":lexpr system('git status -s | awk '' { print $2 \":1:\" $1 } ''') | lopen")
vim.keymap.set('n', '<Leader>cs', ":cexpr system('git status -s | awk '' { print $2 \":1:\" $1 } ''') | copen")
-- Diagnostics
vim.keymap.set('n', '<leader>cd', vim.diagnostic.setqflist)
vim.keymap.set('n', '<leader>ld', vim.diagnostic.setloclist)
-- Move the focus between windows
vim.keymap.set('n', '<C-h>', '<C-w><C-h>')
vim.keymap.set('n', '<C-l>', '<C-w><C-l>')
vim.keymap.set('n', '<C-j>', '<C-w><C-j>')
vim.keymap.set('n', '<C-k>', '<C-w><C-k>')
-- Move windows
vim.keymap.set("n", "<C-S-h>", "<C-w>H")
vim.keymap.set("n", "<C-S-l>", "<C-w>L")
vim.keymap.set("n", "<C-S-j>", "<C-w>J")
vim.keymap.set("n", "<C-S-k>", "<C-w>K")
-- Create window splits
vim.keymap.set('n', '<Leader>hs', '<Cmd>:split<CR>')
vim.keymap.set('n', '<Leader>vs', '<Cmd>:vsplit<CR>')
-- Lsp keymaps
vim.keymap.set('n', 'grf', vim.lsp.buf.format)
vim.keymap.set('n', 'grh', vim.lsp.buf.document_highlight)
-- Enable diagnostic virtual lines
-- See: https://neovim.io/doc/user/diagnostic.html#vim.diagnostic.config()
vim.diagnostic.config({ virtual_text = true})
-- Simply open netrw in the current file's directory
vim.keymap.set('n', '-', ':edit %:h<CR>', { silent = true })
-- Plugins section
-- Install lazy.nvim automatically
-- https://github.com/folke/lazy.nvim
-- Thanks to kickstart.nvim
-- https://github.com/nvim-lua/kickstart.nvim
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
if vim.v.shell_error ~= 0 then
error('Error cloning lazy.nvim:\n' .. out)
end
end ---@diagnostic disable-next-line: undefined-field
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
-- vim-sleuth
-- https://github.com/tpope/vim-sleuth.git
'tpope/vim-sleuth',
-- gitsigns.nvim
-- https://github.com/lewis6991/gitsigns.nvim
{
'https://github.com/lewis6991/gitsigns.nvim',
config = function()
require('gitsigns').setup()
vim.cmd('Gitsigns toggle_current_line_blame')
-- Git diff
vim.keymap.set('n', '<Leader>gd', '<Cmd>:Gitsigns preview_hunk<CR>')
-- Git previous
vim.keymap.set('n', '[g', '<Cmd>:Gitsigns prev_hunk<CR>')
-- Git next
vim.keymap.set('n', ']g', '<Cmd>:Gitsigns next_hunk<CR>')
-- Git reset
vim.keymap.set('n', '<Leader>gr', '<Cmd>:Gitsigns reset_hunk<CR>')
-- Git blame
vim.keymap.set('n', '<Leader>gb', '<Cmd>:Gitsigns blame_line<CR>')
end,
},
-- nvim-jdtls
-- https://github.com/mfussenegger/nvim-jdtls
'mfussenegger/nvim-jdtls',
{
'mason-org/mason-lspconfig.nvim',
dependencies = {
-- mason.nvim
-- https://github.com/mason-org/mason.nvim
{
'mason-org/mason.nvim',
opts = {},
},
-- nvim-lspconfig
-- https://github.com/neovim/nvim-lspconfig
'neovim/nvim-lspconfig',
},
config = function()
require("mason-lspconfig").setup({
ensure_installed = { 'cssls', 'jdtls', 'gopls', 'html', 'ts_ls', 'angularls', 'pyright' },
})
-- Highlight references
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }),
callback = function(event)
local function client_supports_method(client, method, bufnr)
if vim.fn.has 'nvim-0.11' == 1 then
return client:supports_method(method, bufnr)
else
return client.supports_method(method, { bufnr = bufnr })
end
end
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
buffer = event.buf,
group = highlight_augroup,
callback = vim.lsp.buf.clear_references,
})
vim.api.nvim_create_autocmd('LspDetach', {
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
callback = function(event2)
vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
end,
})
end
end,
})
end,
},
{
-- blink.cmp
-- https://github.com/Saghen/blink.cmp
'saghen/blink.cmp',
dependencies = {
-- friendly-snippets
-- https://github.com/rafamadriz/friendly-snippets
'rafamadriz/friendly-snippets',
},
version = '1.*',
branch = 'v1',
opts = {
keymap = {
preset = 'default'
},
completion = {
documentation = {
auto_show = false
}
},
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer', },
},
fuzzy = {
implementation = 'lua',
sorts = {
'exact',
-- defaults
'score',
'sort_text',
},
},
},
opts_extend = { 'sources.default', },
},
{
'folke/todo-comments.nvim',
event = 'VimEnter',
dependencies = { 'nvim-lua/plenary.nvim' },
opts = {
signs = false
}
},
{
'idr4n/github-monochrome.nvim',
lazy = false,
priority = 1000, -- Make sure to load this before all the other start plugins.
config = function()
---@diagnostic disable-next-line: missing-fields
require('github-monochrome').setup {
styles = {
comments = { italic = false }, -- Disable italics in comments
},
}
-- Load the colorscheme here.
-- Like many other themes, this one has different styles, and you could load
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
vim.cmd.colorscheme 'github-monochrome-zenbones'
end,
},
})