-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
182 lines (154 loc) · 4.57 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
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
vim.opt.mouse = "a"
vim.opt.number = true
vim.opt.cursorline = true
vim.opt.scrolloff = 8
vim.opt.showmatch = true
vim.opt.smartcase = true
vim.opt.ignorecase = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true
vim.opt.wildmode = "list:longest,full"
vim.opt.completeopt = "longest,menuone"
-- fileencodings ???
vim.opt.foldmethod = "marker"
vim.opt.foldlevelstart = 99
vim.opt.tags:append(".tags")
vim.opt.undofile = true
vim.opt.clipboard = "unnamedplus"
vim.opt.splitright = true
vim.opt.splitbelow = true
vim.cmd.syntax 'on'
vim.cmd.colorscheme 'onehalflight'
vim.cmd.filetype 'on'
vim.cmd.filetype 'plugin on'
vim.cmd.filetype 'indent on'
vim.api.nvim_create_autocmd('FileType', {pattern = 'python', command = 'setl colorcolumn=99'})
vim.api.nvim_create_autocmd('FileType', {pattern = 'python', command = ':iabbrev pdb import pdb; pdb.set_trace()'})
vim.api.nvim_create_autocmd('FileType', {pattern = 'javascript,javascriptreact,typescript,typescriptreact', command = 'setl tabstop=2 softtabstop=2 shiftwidth=2'})
vim.api.nvim_create_autocmd('FileType', {pattern = 'html,htmldjango', command = 'setl tabstop=2 softtabstop=2 shiftwidth=2'})
-- python indentation
vim.g.pyindent_open_paren = 'shiftwidth()'
vim.g.pyindent_continue = 'shiftwidth()'
-- diagnostics
vim.diagnostic.config({
virtual_text = true,
update_in_insert = false,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
}
})
vim.keymap.set('n', '<space>e', ':lua vim.diagnostic.open_float(0, {scope="line"})<CR>')
-- Plug
local Plug = vim.fn['plug#']
vim.call('plug#begin')
Plug 'nvim-lua/plenary.nvim'
Plug('nvim-telescope/telescope.nvim', {tag = '0.1.8'})
Plug 'preservim/nerdtree'
Plug 'neovim/nvim-lspconfig'
Plug ('FabijanZulj/blame.nvim', {opts = {blame_options = {'-w'}}})
Plug 'prettier/vim-prettier'
vim.call('plug#end')
-- nerdtree
vim.g.NERDTreeShowHidden = 1
vim.keymap.set('n', '<C-n>', ':NERDTreeToggle<CR>')
-- telescope
local builtin = require('telescope.builtin')
-- file search
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
-- fuzzy search using ripgrep and telescope
vim.api.nvim_create_user_command(
'RG',
function(opts)
builtin.live_grep()
end,
{nargs = '*'}
)
-- fuzzy search without migrations
vim.api.nvim_create_user_command(
'RGNM',
function(opts)
builtin.live_grep({glob_pattern = '!migrations'})
end,
{nargs = '*'}
)
-- fuzzy search with glob
vim.api.nvim_create_user_command(
'RGG',
function(opts)
builtin.live_grep({glob_pattern = opts.fargs[1]})
end,
{nargs = 1}
)
-- git blame
local blame = require('blame')
blame.setup({
date_format = "%d.%m.%Y",
virtual_style = "right_align",
views = {
window = window_view,
virtual = virtual_view,
default = window_view,
},
focus_blame = true,
merge_consecutive = false,
max_summary_width = 30,
colors = nil,
blame_options = nil,
commit_detail_view = "vsplit",
--format_fn = blame.formats.commit_date_author_fn,
mappings = {
commit_info = "i",
stack_push = "<TAB>",
stack_pop = "<BS>",
show_commit = "<CR>",
close = { "<esc>", "q" },
}
})
vim.keymap.set('n', 'xx', ':BlameToggle<CR>')
-- lspconfig
local lsp_formatting = vim.api.nvim_create_augroup("LspFormatting", {})
local on_attach = function(_, bufnr)
vim.api.nvim_create_autocmd('BufWritePre', { group = lsp_formatting, buffer = bufnr, callback = function() vim.lsp.buf.format() end })
end
-- pip install python-lsp-server
-- pip install python-lsp-ruff
-- pip install pylsp-mypy
require'lspconfig'.pylsp.setup{
on_attach = on_attach,
settings = {
pylsp = {
plugins = {
pylsp_mypy = {
enabled = true,
live_mode = false,
dmypy = true,
report_progress = true
},
ruff = {
enabled = true,
formatEnabled = true
},
pyflakes = {
enabled = false
},
pycodestyle = {
enabled = false,
}
}
}
}
}
-- npm install -g typescript typescript-language-server
require'lspconfig'.ts_ls.setup({})
-- vim-prettier
vim.api.nvim_set_var('prettier#autoformat', 0)
-- run Prettier only on defined file types:
vim.api.nvim_create_autocmd('BufWritePre', { group = Prettier, pattern = {"*.js", "*.jsx", "*.mjs", "*.cjs", "*.ts", "*.tsx", "*.css", "*.less", "*.scss", "*.json", "*.graphql", "*.gql", "*.vue", "*.svelte"}, buffer = bufnr, callback = function() vim.call('prettier#Prettier') end })