-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
198 lines (179 loc) · 6 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
-- Conditionally require module
local function try_require(module_name)
local should_return_module, module = pcall(require, module_name)
return function()
if should_return_module then
should_return_module = false -- only loop once
return module
end
end
end
-- Ensure lazy.nvim
local lazy_nvim_path = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazy_nvim_path) then
vim.fn.system {
'git', 'clone',
'--filter=blob:none',
'--branch=stable',
'https://github.com/folke/lazy.nvim.git',
lazy_nvim_path,
}
end
vim.opt.rtp:prepend(lazy_nvim_path)
for lazy in try_require 'lazy' do
lazy.setup {
-- Colorschemes
{ 'Jzice/vim-colorschemes',
config = function()
vim.cmd 'colorscheme PaperColor'
end,
},
-- Status
{ 'vim-airline/vim-airline',
init = function()
vim.g.airline_powerline_fonts = true
end,
},
{ 'vim-airline/vim-airline-themes' },
-- Adding color to all buffers based on content
{ 'ap/vim-css-color' },
{ 'powerman/vim-plugin-AnsiEsc' },
-- General functionality
{ 'preservim/nerdtree',
init = function()
vim.g.NERDTreeWinSize = 40
vim.g.NERDTreeShowHidden = true
end,
},
{ 'tpope/vim-fugitive' },
{ 'tpope/vim-abolish' },
{ 'sjshuck/vim-hs-sort-imports' },
--'~/code/vim-hs-sort-imports',
{ 'iamcco/markdown-preview.nvim' }, -- must :call mkdp#util#install() once
-- LSP, completion
{ 'neovim/nvim-lspconfig' },
{ 'hrsh7th/nvim-cmp' },
{ 'hrsh7th/cmp-nvim-lsp' },
-- Syntax highlighting
{ 'OrangeT/vim-csharp' },
{ 'neovimhaskell/haskell-vim',
init = function()
vim.g.haskell_indent_disable = true
end,
},
{ 'purescript-contrib/purescript-vim',
init = function()
vim.g.purescript_unicode_conceal_enable = false
end,
},
{ 'vmchale/dhall-vim' },
{ 'udalov/kotlin-vim' },
{ 'elixir-editors/vim-elixir' },
{ 'hashivim/vim-terraform' },
{ 'vito-c/jq.vim' },
{ 'cespare/vim-toml' },
{ 'kongo2002/fsharp-vim' },
{ 'lnl7/vim-nix' },
{ 'idris-hackers/idris-vim' },
}
end
vim.opt.termguicolors = true
vim.opt.background = 'dark'
vim.g.enable_bold_font = true
vim.g.enable_italic_font = true
vim.opt.splitright = true
vim.opt.number = true
vim.opt.colorcolumn = '81'
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smarttab = true
vim.opt.mouse = 'a'
vim.cmd [[
autocmd filetype ruby,yaml,html,xml set shiftwidth=2
autocmd bufnewfile,bufread Jenkinsfile set filetype=groovy
autocmd bufnewfile,bufread Dockerfile.* set filetype=dockerfile
autocmd bufnewfile,bufread tsconfig.json set filetype=jsonc
autocmd bufnewfile,bufread *.fsproj set filetype=xml
autocmd bufnewfile,bufread * syntax sync fromstart
]]
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local function nmap(seq, what, opts)
local all_opts = { noremap = true, silent = true }
if opts then
for k, v in pairs(opts) do all_opts[k] = v end
end
return vim.keymap.set('n', seq, what, all_opts)
end
nmap('<space>e', vim.diagnostic.open_float)
nmap('[d', vim.diagnostic.goto_prev)
nmap(']d', vim.diagnostic.goto_next)
nmap('<space>q', vim.diagnostic.setloclist)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local function lsp_on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local nmap = function(seq, what)
return nmap(seq, what, { buffer = bufnr })
end
nmap('gD', vim.lsp.buf.declaration)
nmap('gd', vim.lsp.buf.definition)
nmap('K', vim.lsp.buf.hover)
nmap('gi', vim.lsp.buf.implementation)
nmap('<C-k>', vim.lsp.buf.signature_help)
nmap('<space>wa', vim.lsp.buf.add_workspace_folder)
nmap('<space>wr', vim.lsp.buf.remove_workspace_folder)
nmap('<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end)
nmap('<space>D', vim.lsp.buf.type_definition)
nmap('<space>rn', vim.lsp.buf.rename)
nmap('<space>ca', vim.lsp.buf.code_action)
nmap('gr', vim.lsp.buf.references)
nmap('<space>f', vim.lsp.buf.formatting)
end
local lsp_flags = {
-- This is the default in Nvim 0.7+
debounce_text_changes = 150,
}
local lsp_capabilities = nil
for cmp_nvim_lsp in try_require 'cmp_nvim_lsp' do
lsp_capabilities = cmp_nvim_lsp.default_capabilities()
end
for lspconfig in try_require 'lspconfig' do
local function lsp_server_setup(server, opts)
local all_opts = {
on_attach = lsp_on_attach,
flags = lsp_flags,
capabilities = lsp_capabilities,
}
if opts then
for k, v in pairs(opts) do all_opts[k] = v end
end
return lspconfig[server].setup(all_opts)
end
lsp_server_setup 'bashls'
lsp_server_setup 'dhall_lsp_server'
lsp_server_setup 'fsautocomplete'
lsp_server_setup 'hls'
lsp_server_setup 'kotlin_language_server'
lsp_server_setup 'lua_ls'
lsp_server_setup 'purescriptls'
lsp_server_setup 'pyright'
lsp_server_setup 'terraformls'
lsp_server_setup 'tsserver'
end
for cmp in try_require 'cmp' do
cmp.setup {
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
},
sources = cmp.config.sources {
{ name = 'nvim_lsp' },
},
}
end