-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.vim
249 lines (207 loc) · 5.72 KB
/
init.vim
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
set nocompatible " be improved, required
filetype plugin indent on " Required
" core basic settings
set laststatus=2
syntax on
set ruler
set number
set showmatch
set noswapfile
set number relativenumber
set splitright
set shiftwidth=2
set tabstop=2
set backspace=2
set encoding=utf-8
" screen auto resize
set winwidth=80
set winheight=5
set winminheight=5
set winheight=1000
"leader
let mapleader =" "
call plug#begin('~/.config/nvim/plugged')
Plug 'kyazdani42/nvim-web-devicons'
Plug 'phaazon/hop.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'neovim/nvim-lspconfig'
Plug 'williamboman/nvim-lsp-installer'
Plug 'jiangmiao/auto-pairs'
Plug 'kyazdani42/nvim-tree.lua'
Plug 'tpope/vim-surround'
Plug 'numToStr/Comment.nvim'
Plug 'lukas-reineke/indent-blankline.nvim'
Plug 'ap/vim-css-color'
Plug 'machakann/vim-highlightedyank'
Plug 'yuezk/vim-js'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'mhartington/formatter.nvim'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'EdenEast/nightfox.nvim'
Plug 'TovarishFin/vim-solidity'
Plug 'connorholyday/vim-snazzy'
" completion libraries
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-vsnip'
Plug 'hrsh7th/vim-vsnip'
Plug 'onsails/lspkind-nvim'
" libraries used by other libs
Plug 'nvim-lua/plenary.nvim'
Plug 'simrat39/rust-tools.nvim'
Plug 'nvim-lua/popup.nvim'
Plug 'mfussenegger/nvim-dap'
call plug#end()
" LSP setup automatic
lua << EOF
require("nvim-lsp-installer").setup {}
EOF
" Hop Settings
lua << EOF
require'hop'.setup()
EOF
nnoremap <silent><leader>f :HopWord<CR>
"nnoremap <silent><leader>f :HopChar1<CR>
" telescope settings
nnoremap <c-p> <cmd>Telescope find_files<cr>
nnoremap <leader>ff <cmd>Telescope live_grep<cr>
nnoremap <c-b> <cmd>Telescope buffers<cr>
lua << EOF
require('telescope').setup{
defaults = { file_ignore_patterns = { '.gitignore', 'ios' }}
}
EOF
lua << END
require'nvim-tree'.setup()
END
let g:nvim_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default
nnoremap <C-n> :NvimTreeToggle<CR>
lua << EOF
require('Comment').setup()
EOF
lua << EOF
require('indent_blankline').setup()
EOF
"Hightlight duration
let g:highlightedyank_highlight_duration = 300
"colorscheme gruvbox
"colorscheme hybrid
"colorscheme tender
colorscheme nightfox
"hi Normal ctermbg=16 guibg=#000000
"hi LineNr ctermbg=16 guibg=#000000
hi Visual guifg=Black guibg=Yellow gui=none
highlight IncSearch gui=underline,bold guifg=black guibg=yellow
"snippet/autocomplete menu
set completeopt=menu,menuone,noselect
lua <<EOF
local cmp = require'cmp'
local lspkind = require('lspkind')
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end
},
mapping = {
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
['<C-y>'] = cmp.config.disable,
['<C-e>'] = cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
}),
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }),
},
sources = {
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'buffer' },
{ name = "path" },
},
formatting = {
format = lspkind.cmp_format({with_text = true, maxwidth = 50, menu = {
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
vsnip = "[vsnip]",
latex_symbols = "[Latex]",
}})
},
})
EOF
let g:vsnip_snippet_dir = expand('~/.config/nvim/snippets')
lua << EOF
local vim = vim
local format = require("formatter")
local prettier = function()
return {
exe = "prettier",
args = {"--stdin-filepath", vim.fn.shellescape(vim.api.nvim_buf_get_name(0)), "--single-quote"},
stdin = true,
}
end
format.setup {
logging = false,
filetype = {
javascript = { prettier },
typescript = {prettier },
javascriptreact = { prettier },
markdown = { prettier },
json = { prettier },
vim = { prettier },
},
}
vim.api.nvim_exec(
[[
augroup FormatAutogroup
autocmd!
autocmd BufWritePost *.js,*.jsx,*.json FormatWrite
augroup END
]],
true
)
EOF
" Jump forward or backward in snippets
imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>'
imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>'
lua << EOF
local nvim_lsp = require'lspconfig'
local on_attach = function(client)
require'completion'.on_attach(client)
end
nvim_lsp.rust_analyzer.setup({
on_attach=on_attach,
settings = {
["rust-analyzer"] = {
assist = {
importGranularity = "module",
importPrefix = "by_self",
},
cargo = {
loadOutDirsFromCheck = true
},
procMacro = {
enable = true
},
}
}
})
require('rust-tools').setup({})
EOF
lua << EOF
require'lspconfig'.solc.setup{}
EOF
" themes for airline status bar
let g:airline_powerline_fonts = 1
let g:airline_theme='luna'
"This unsets the last search pattern register by hitting return
nnoremap <CR> :noh<CR><CR>