-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.lua
155 lines (136 loc) · 3.89 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
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local plugins = {
--{ 'github/copilot.vim' },
{ 'AlexvZyl/nordic.nvim' },
{ 'neovim/nvim-lspconfig' },
--- make things a bit Luan's vim-ier
{ 'ctrlpvim/ctrlp.vim' },
{ 'kevinhwang91/promise-async' },
{ 'kevinhwang91/nvim-ufo' },
{ 'nvim-treesitter/nvim-treesitter', build = ":TSUpdate" },
{
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
},
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" }
},
{
'nvim-telescope/telescope.nvim',
tag = '0.1.2',
dependencies = { 'nvim-lua/plenary.nvim' }
}
}
require("lazy").setup(plugins)
vim.o.foldcolumn = '1' -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
require("mason").setup()
require("mason-lspconfig").setup()
require("mason-lspconfig").setup {
ensure_installed = { "lua_ls", "rust_analyzer" },
}
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
--local language_servers = require("lspconfig").util.available_servers() -- or list servers manually like {'gopls', 'clangd'}
local language_servers = { 'lua_ls', 'elmls', 'gopls' }
for _, ls in ipairs(language_servers) do
require('lspconfig')[ls].setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = { globals = { 'vim' } }
}
}
-- you can add other fields for setting up lsp server in this table
})
end
require('ufo').setup()
--- fancy syntax highlighting
require 'nvim-treesitter.configs'.setup {
ensure_installed = {
"css",
"elm",
"go",
"html",
"javascript",
"lua"
},
highlight = { enable = true },
}
-- Format on writes
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = vim.fn.bufnr(),
callback = function()
vim.lsp.buf.format({ timeout_ms = 3000 })
end,
})
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
--- keybindings
local wk = require("which-key")
wk.register({
f = {
name = "file", -- optional group name
f = { "<cmd>Telescope find_files<cr>", "Find File" }, -- create a binding with label
g = { "<cmd>Telescope live_grep<cr>", "Full Text Search" },
b = { "<cmd>Telescope buffers<cr>", "Buffers" },
},
d = {
name = "diagnostic",
o = { "<cmd>lua vim.diagnostic.open_float()<cr>", "Open Diagnostic" },
n = { "<cmd>lua vim.diagnostic.goto_next()<cr>", "Next Diagnostic" },
p = { "<cmd>lua vim.diagnostic.goto_prev()<cr>", "Previous Diagnostic" },
d = { "<cmd>Telescope diagnostics<cr>", "List Diagnostics" }
},
}, { prefix = "<leader>" })
vim.api.nvim_create_autocmd({ "LspAttach" }, {
callback = function()
wk.register({
g = {
name = "Goto",
d = { vim.lsp.buf.definition, "Go to definition" },
r = { require("telescope.builtin").lsp_references,
"Open a telescope window with references" },
},
}, { buffer = 0 })
end
})
-- autosave
vim.opt.autowriteall = true
--- somehow, this stops Nvim from adding a tab
--- when it autoindents a line
--= in addition to the spaces its copying from the above line
vim.opt.tabstop = 2
vim.opt.softtabstop = 2
--- set line numbers for pairing
vim.opt.number = true
--- enable syntax highlighting
vim.opt.syntax = "on"
--- enable 24-bit RGB colors
vim.opt.termguicolors = true
--- set the colorscheme
vim.cmd("colorscheme nordic")