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
| call plug#begin('~/.config/nvim/plugged')
" Your Plug commands will go here, for example:
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'hrsh7th/nvim-cmp' " The completion engine
Plug 'hrsh7th/cmp-buffer' " Buffer completions
Plug 'hrsh7th/cmp-path' " Path completions
Plug 'hrsh7th/cmp-nvim-lsp' " LSP completions
Plug 'hrsh7th/cmp-nvim-lua' " Neovim Lua API completions
Plug 'neovim/nvim-lspconfig' " Common configurations for the Neovim LSP client
Plug 'hrsh7th/cmp-vsnip' " Snippet completions
Plug 'hrsh7th/vim-vsnip' " Snippet engine
call plug#end()
" install programming language packs
lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true, -- false will disable the whole extension
},
ensure_installed = "all" -- one of "all", "maintained" (parsers with maintainers), or a list of languages
}
EOF
" Install for predicting typing
lua << EOF
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
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({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
{ name = 'buffer' },
{ name = 'path' }
})
})
EOF
" Powerful Diagnostic Functionality
lua << EOF
-- PYTHON
require'lspconfig'.pyright.setup{}
-- YAML
require'lspconfig'.yamlls.setup{}
-- JSON
require'lspconfig'.jsonls.setup{
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, {0,0}, {vim.fn.line("$"),0})
end
}
}
}
-- Bash
require'lspconfig'.bashls.setup{}
-- JavaScript and TypeScript
require'lspconfig'.tsserver.setup{}
-- HTML
require'lspconfig'.html.setup{}
-- CSS
require'lspconfig'.cssls.setup{}
EOF
" toggle diagnostics
lua << EOF
function ToggleDiagnostics()
local current_value = vim.diagnostic.config().underline
vim.diagnostic.config({underline = not current_value, virtual_text = not current_value, signs = not current_value, update_in_insert = not current_value})
end
EOF
" The Leader key defaults to \. You can change it by uncommenting and setting the line below:
" let mapleader = " "
nnoremap <leader>d :lua ToggleDiagnostics()<CR>
" Set tab to 4 spaces
set tabstop=4
set shiftwidth=4
set expandtab
" Always show line numbers
set number
" Toggle relative line numbers with F7
nnoremap <F7> :if &relativenumber == 0 \| set relativenumber \| else \| set norelativenumber \| endif<CR>
|