-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
86 lines (79 loc) · 2.56 KB
/
init.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
75
76
77
78
79
80
81
82
83
84
85
86
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set('n', '<leader>vd', vim.diagnostic.open_float)
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
local options = {
mouse = "a",
cursorline = true,
tabstop = 4,
shiftwidth = 4,
softtabstop = 4,
expandtab = true,
autoread = true,
nu = true,
foldlevelstart = 99,
scrolloff = 10,
writebackup = false,
clipboard = "unnamedplus",
showmode = false,
swapfile = false,
backup = false,
undodir = os.getenv("HOME") .. "/.vim/undodir",
undofile = true,
smartindent = true,
relativenumber = true,
guicursor = "",
termguicolors = true,
}
for k, v in pairs(options) do
vim.opt[k] = v
end
-- lazy stuff
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins")
-- highlight when yanking
vim.api.nvim_create_autocmd('TextYankPost', {
desc = "Highlight when yanking text",
group = vim.api.nvim_create_augroup('highlight-yank', {clear = true}),
callback = function()
vim.highlight.on_yank()
end,
})
-- LSP setup
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
-- replaced with neoformat
-- vim.keymap.set('n', '<leader>f', function()
-- vim.lsp.buf.format { async = true }
-- end, opts)
end,
})