-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
83 lines (74 loc) · 1.83 KB
/
Copy pathinit.lua
File metadata and controls
83 lines (74 loc) · 1.83 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
vim.opt.tabstop = 4
vim.keymap.set('n', '<A-Left>', ':bprev<CR>')
vim.keymap.set('n', '<A-Right>', ':bnext<CR>')
-- Go
vim.lsp.config['go'] = {
cmd = { 'gopls' },
filetypes = { 'go', 'gomod', 'gowork' },
rootmarkers = { 'go.mod' }
}
vim.lsp.enable('go')
-- Lua
vim.api.nvim_create_autocmd('FileType', {
pattern = 'lua',
callback = function()
vim.bo.expandtab = true
vim.bo.shiftwidth = 2
vim.bo.tabstop = 2
end
})
-- C/C++
vim.lsp.config['c'] = {
cmd = { 'clangd' },
filetypes = { 'c', 'cpp' },
rootmarkers = { 'Makefile' }
}
vim.lsp.enable('c')
vim.api.nvim_create_autocmd('FileType', {
pattern = { 'c', 'cpp' },
callback = function()
vim.bo.cino = ':0'
end
})
-- Python
vim.lsp.config['python'] = {
cmd = { 'pylsp' },
filetypes = { 'python' },
rootmarkers = { 'requirements.txt' },
settings = {
pylsp = {
plugins = {
black = { enabled = true },
isort = { enabled = true }
}
}
}
}
vim.lsp.enable('python')
-- Autoformatting
vim.api.nvim_create_autocmd('BufWritePre', {
pattern = { '*.go', '*.py' },
callback = function()
vim.lsp.buf.format()
end
})
-- Restore last cursor position when reopening a file
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"') -- last-position mark
local lnum, col = mark[1], mark[2]
if lnum > 0 and lnum <= vim.api.nvim_buf_line_count(0) then
pcall(vim.api.nvim_win_set_cursor, 0, {lnum, col})
end
end,
})
-- Plugins
vim.pack.add({
-- Color schemes
'https://github.com/ayu-theme/ayu-vim',
'https://github.com/tjammer/blayu.vim',
'https://github.com/Alligator/accent.vim',
'https://github.com/jeffkreeftmeijer/vim-dim',
})
-- :lua vim.pack.del(vim.iter(vim.pack.get()):map(function(x) return x.spec.name end):totable())
vim.cmd.colorscheme("ayu")