-
Notifications
You must be signed in to change notification settings - Fork 1
/
nvim.yaml
224 lines (201 loc) · 8.12 KB
/
nvim.yaml
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
nvim:
plugins:
# bootstrap
- name: savq/paq-nvim
# themeing
- name: KeitaNakamura/neodark.vim
# code navigation
- name: rafaqz/ranger.vim
- name: junegunn/fzf
- name: junegunn/fzf.vim
# vim enhancements
- name: nvim-lua/plenary.nvim
- name: lewis6991/gitsigns.nvim
- name: mhinz/vim-sayonara
- name: tpope/vim-abolish
- name: numToStr/Comment.nvim
- name: tpope/vim-fugitive
- name: tpope/vim-repeat
- name: tpope/vim-rhubarb
- name: tpope/vim-sensible
- name: tpope/vim-surround
- name: tpope/vim-unimpaired
- name: nvim-treesitter/nvim-treesitter # TODO run TSUpdate on install/update
# vim editing enhancements
- name: itchyny/vim-cursorword
- name: windwp/nvim-autopairs
- name: ntpeters/vim-better-whitespace
- name: machakann/vim-swap
- name: PeterRincker/vim-argumentative
- name: wellle/targets.vim
- name: chrisbra/SudoEdit.vim
- name: AndrewRadev/splitjoin.vim
# LSP
- name: neovim/nvim-lspconfig
- name: hrsh7th/cmp-nvim-lsp
- name: hrsh7th/cmp-buffer
- name: hrsh7th/cmp-path
- name: hrsh7th/nvim-cmp
- name: ray-x/lsp_signature.nvim
# telescope
# - name: nvim-telescope/telescope-fzf-native.nvim # TODO after adding run support
- name: gbrlsnchs/telescope-lsp-handlers.nvim
- name: nvim-telescope/telescope.nvim
config: |
----------------------------------------
-- options
----------------------------------------
vim.cmd("colorscheme neodark")
vim.opt.autoread = true
vim.opt.clipboard = {"unnamed", "unnamedplus"}
vim.opt.cursorline = true
vim.opt.visualbell = true
vim.opt.mouse = "a"
vim.opt.inccommand = "nosplit"
vim.opt.wrap = false
vim.opt.number = true
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 4
vim.opt.softtabstop = 4
vim.opt.smarttab = true
vim.opt.tabstop = 4
vim.opt.completeopt = {"menuone", "noinsert", "noselect"}
vim.opt.shortmess = vim.opt.shortmess + "c"
----------------------------------------
-- mappings
----------------------------------------
function map(mode, lhs, rhs, opts)
local options = {noremap = true}
if opts then options = vim.tbl_extend("force", options, opts) end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
map("n", "Y", "y$")
map("n", "B", "^")
map("n", "E", "$")
map("n", "<C-n>", ":noh<CR>")
map("n", "j", "gj")
map("n", "k", "gk")
map("t", "<Esc>", "<C-\\><C-n>")
map("n", "<C-h>", "<C-w>h")
map("n", "<C-j>", "<C-w>j")
map("n", "<C-k>", "<C-w>k")
map("n", "<C-l>", "<C-w>l")
----------------------------------------
-- plugin setup and config
----------------------------------------
-- fzf
map("n", "<C-f>", ":Rg<cr>")
vim.g.fzf_preview_window = ""
-- better whitespace
vim.g.better_whitespace_enabled = 0
vim.g.strip_whitelines_at_eof = 1
vim.g.strip_whitespace_confirm = 0
vim.g.strip_whitespace_on_save = 1
-- sayonara
map("n", "<C-c>", ":Sayonara!<cr>")
-- gitsigns
require('gitsigns').setup({
signs = {delete = {show_count=true}}
})
-- vim-swap
map("o", "i,", "<Plug>(swap-textobject-i)")
map("x", "i,", "<Plug>(swap-textobject-i)")
map("o", "a,", "<Plug>(swap-textobject-a)")
map("x", "a,", "<Plug>(swap-textobject-a)")
-- treesitter
require "nvim-treesitter.configs".setup {
ensure_installed = "maintained",
highlight = { enable = true },
indent = { enable = true },
}
-- autopairs
require("nvim-autopairs").setup({ check_ts = true })
-- comment
require('Comment').setup()
-- telescope
local telescope = require("telescope")
telescope.setup({})
telescope.load_extension('lsp_handlers')
map("n", "<C-p>", ":lua require'telescope.builtin'.git_files()<CR>", silent)
map("n", "<space>ff", ":lua require'telescope.builtin'.find_files()<CR>", silent)
map("n", "<space>fh", ":lua require'telescope.builtin'.help_tags()<CR>", silent)
map("n", "<space>fg", ":lua require('telescope.builtin').live_grep()<CR>", silent)
map("n", "<space>fk", ":lua require('telescope.builtin').keymaps()<CR>", silent)
map("n", "<space>fc", ":lua require('telescope.builtin').git_commits()<CR>", silent)
map("n", "<space>fj", ":lua require('telescope.builtin').git_bcommits()<CR>", silent)
map("n", "<space>fd", ":lua require('telescope.builtin').lsp_workspace_diagnostics()<CR>", silent)
map("n", "<space>fs", ":lua require('telescope.builtin').lsp_dynamic_workspace_symbols()<CR>", silent)
map("n", "<space>fb", ":lua require('telescope.builtin').buffers()<CR>", silent)
map("n", "<space>fr", ":lua require('telescope.builtin').file_browser()<CR>", silent)
-- completions & LSP
local cmp = require('cmp')
cmp.setup({
completion = {
keyword_length = 3,
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
}, {
{ name = 'buffer' },
}),
})
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
local on_attach = function()
-- vim.api.nvim_set_keymap("n", "<Leader>o", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "ga", "<cmd>lua vim.lsp.buf.code_action()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", {noremap = true, silent = true})
-- vim.api.nvim_set_keymap("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "gn", "<cmd>lua vim.lsp.diagnostic.goto_next()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "gp", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "<Leader>r", "<cmd>lua vim.lsp.buf.rename()<CR>", {noremap = true, silent = true})
vim.api.nvim_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", {noremap = true, silent = true})
-- vim.api.nvim_set_keymap("n", "<C-i>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", {noremap = true, silent = true})
-- vim.api.nvim_set_keymap("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", {noremap = true, silent = true})
-- vim.api.nvim_set_keymap("n", "gW", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>", {noremap = true, silent = true})
end
local lspconfig = require('lspconfig')
lspconfig.gopls.setup{
on_attach = on_attach,
capabilities = capabilities,
cmd = {"gopls"},
flags = {debounce_text_changes = 500},
settings = {
gopls = {
buildFlags = {"-tags=integration"},
usePlaceholders = true, --enables placeholders for function parameters or struct fields in completion responses
analyses = {unusedparams = true},
staticcheck = true,
},
},
}
lspconfig.pyright.setup{}
require "lsp_signature".setup()
----------------------------------------
-- augroups
----------------------------------------
-- auto_format_lsp formats current buffer if attached lsp client
-- has 'document_formatting' capability
function auto_format_lsp()
local id, client = next(vim.lsp.buf_get_clients())
if id ~= nil and client.resolved_capabilities.document_formatting then
vim.lsp.buf.formatting_sync(nil, 100)
end
end
vim.cmd[[
augroup lsp
autocmd!
autocmd BufWritePre * lua auto_format_lsp()
augroup END
]]
-- go configurations
vim.cmd[[
augroup golang
autocmd!
au FileType go setlocal tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab
augroup END
]]