-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.local
210 lines (180 loc) · 6.17 KB
/
vimrc.local
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
set nocursorline " don't highlight current line
set wildignorecase
" keyboard shortcuts
nnoremap <leader>s :SaveSession<CR>
nnoremap <leader>w :wa<CR>
" set background=dark
colorscheme onehalfdark
let g:airline_theme='onehalfdark'
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" Disambiguate ,a & ,t from the Align plugin, making them fast again.
"
" This section is here to prevent AlignMaps from adding a bunch of mappings
" that interfere with the very-common ,a and ,t mappings. This will get run
" at every startup to remove the AlignMaps for the *next* vim startup.
"
" If you do want the AlignMaps mappings, remove this section, remove
" ~/.vim/bundle/Align, and re-run rake in maximum-awesome.
function! s:RemoveConflictingAlignMaps()
if exists("g:loaded_AlignMapsPlugin")
AlignMapsClean
endif
endfunction
command! -nargs=0 RemoveConflictingAlignMaps call s:RemoveConflictingAlignMaps()
silent! autocmd VimEnter * RemoveConflictingAlignMaps
let g:session_autosave = 'no'
let g:session_autoload = 'no'
noremap <leader>j <ESC>:FormatCode<CR>
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what i use
nnoremap <leader>ev :vsplit $MYVIMRC<CR>
let g:CommandTMaxFiles=200000
let g:CommandTFileScanner = 'watchman'
vnoremap // y/<C-R>"<CR>
" Fix warning everytime vim is started
" let g:snipMate = { 'snippet_version' : 1 }
set completeopt=menu,menuone,noselect
lua << EOF
local cmp = require'cmp'
local lspconfig = require'lspconfig'
cmp.setup({
snippet = {
-- REQUIRED by nvim-cmp. get rid of it once we can
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
-- TODO: currently snippets from lsp end up getting prioritized -- stop that!
{ name = 'nvim_lsp' },
}, {
{ name = 'path' },
}),
experimental = {
ghost_text = true,
},
})
-- Enable completing paths in :
cmp.setup.cmdline(':', {
sources = cmp.config.sources({
{ name = 'path' }
})
})
-- Copy from nvim-lspconfig. Use vsplit instead of edit.
function switch_source_header_split(bufnr)
local util = require 'lspconfig.util'
bufnr = util.validate_bufnr(bufnr)
local clangd_client = util.get_active_client_by_name(bufnr, 'clangd')
local params = { uri = vim.uri_from_bufnr(bufnr) }
if clangd_client then
clangd_client.request('textDocument/switchSourceHeader', params, function(err, result)
if err then
error(tostring(err))
end
if not result then
print 'Corresponding file cannot be determined'
return
end
vim.api.nvim_command('vsplit ' .. vim.uri_to_fname(result))
end, bufnr)
else
print 'method textDocument/switchSourceHeader is not supported by any servers active on the current buffer'
end
end
-- Setup lspconfig.
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
--Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', '<space>r', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<space>a', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.set_loclist()<CR>', opts)
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
buf_set_keymap("n", "<leader>q", "<cmd>lua switch_source_header_split(0)<CR>", opts)
-- Get signatures (and _only_ signatures) when in argument lists.
require "lsp_signature".on_attach({
doc_lines = 0,
handler_opts = {
border = "none"
},
})
end
local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lsp_status = require('lsp-status')
lsp_status.register_progress()
lspconfig.rust_analyzer.setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
},
settings = {
["rust-analyzer"] = {
completion = {
postfix = {
enable = false,
},
},
},
},
capabilities = capabilities,
}
-- C++ LSP
lspconfig.clangd.setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
},
cmd = {"clangd-15", "--clang-tidy=false"},
capabilities = capabilities,
}
-- Golang LSP
lspconfig.gopls.setup {
on_attach = on_attach,
flags = {
debounce_text_changes = 150,
},
capabilities = capabilities,
}
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
virtual_text = true,
signs = true,
update_in_insert = true,
}
)
EOF
" Statusline
function! LspStatus() abort
if luaeval('#vim.lsp.buf_get_clients() > 0')
return luaeval("require('lsp-status').status()")
endif
return ''
endfunction