-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
351 lines (283 loc) · 10.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
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
vim.g.mapleader = " "
vim.api.nvim_set_keymap('i', 'jk', '<ESC>', { noremap = true })
vim.o.relativenumber = true
vim.cmd "set linebreak"
vim.cmd "set cursorline"
require('packer').startup(function(use)
use 'wbthomason/packer.nvim'
-- mason lsp installer
use { "williamboman/mason.nvim" }
-- rich presence
use 'andweeb/presence.nvim'
--zen-mode
use {"folke/zen-mode.nvim",
config = function()
require("zen-mode").setup {
}
end
}
use { "folke/twilight.nvim",
config = function()
require("twilight").setup {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
end
}
-- bufferline
use {'akinsho/bufferline.nvim', tag = "v2.*", requires = 'kyazdani42/nvim-web-devicons'}
-- lualine
use {'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true }}
-- nvim termtoggle
use {"akinsho/toggleterm.nvim", tag = '*', config = function()
require("toggleterm").setup()
end}
-- comment.nvim
use {'numToStr/Comment.nvim',
config = function()
require('Comment').setup()
end}
-- colorscheme
use 'folke/tokyonight.nvim'
-- autopair
use {"windwp/nvim-autopairs", config = function()
require("nvim-autopairs").setup {} end}
-- treesitter plugin
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
use 'p00f/nvim-ts-rainbow'
use 'nvim-treesitter/playground'
-- nvim-tree plugin
use {'kyazdani42/nvim-tree.lua', requires = {'kyazdani42/nvim-web-devicons'},
tag = 'nightly'}
-- mark-down preview nvim
-- install without yarn or npm
use({"iamcco/markdown-preview.nvim",run = function() vim.fn["mkdp#util#install"]() end,})
use 'ferrine/md-img-paste.vim'
-- plenary
use 'nvim-lua/plenary.nvim'
-- Telescope
use {'nvim-telescope/telescope.nvim'}
-- start of vim-cmp
use 'neovim/nvim-lspconfig' -- configurations for Nvim LSP
use 'hrsh7th/cmp-nvim-lsp'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-cmdline'
use 'hrsh7th/nvim-cmp'
-- For Luasnip users
use 'L3MON4D3/LuaSnip'
use 'saadparwaiz1/cmp_luasnip'
vim.g.completeopt="menu,menuone,noselect"
local cmp = require'cmp'
cmp.setup({
snippet = {expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` 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(),
-- Accept currently selected item.
-- Set `select` to `false` to only confirm explicitly selected items.
['<CR>'] = cmp.mapping.confirm({select = true} ), } ),
sources = cmp.config.sources({
{name = 'nvim_lsp'},
-- For luasnip users
{name = 'luasnip'},},
{ {name = 'buffer'},})})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{name = 'cmp_git'}, -- You can specify the `cmp_git` source if you were installed it.
},{{name = 'buffer'}, } ) } )
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline('/', {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{name = 'buffer'}}})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{name = 'path'}}, {
{name = 'cmdline'}})})
-- Set up lspconfig.
local capabilities = require("cmp_nvim_lsp").default_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true
require'lspconfig'.html.setup{
capabilities = capabilities,
}
-- For css server setup
require'lspconfig'.cssls.setup {capabilities = capabilities,}
-- For Typescript server setup
require'lspconfig'.tsserver.setup{capabilities = capabilities,}
-- For Pyright server setup
require'lspconfig'.pyright.setup {capabilities = capabilities,}
-- For Pylsp server setup
require'lspconfig'.pylsp.setup{capabilities = capabilities,}
-- For marksman server setup
require'lspconfig'.marksman.setup{capabilities = capabilities,}
-- For C server setup
require'lspconfig'.clangd.setup{capabilities = capabilities}
end)
-- empty setup using defaults
require("nvim-tree").setup()
-- treesitter setup
require'nvim-treesitter.configs'.setup {
ensure_installed = { "c", "lua", "rust", "html", "javascript", "python", "css", "markdown"},
-- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false,
auto_install = true,
highlight = {enable = true,
additional_vim_regex_highlighting = false,},
rainbow = {
enable = true,
-- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for
extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean
max_file_lines = nil, -- Do not enable for files with more than n lines, int
-- colors = {}, -- table of hex strings
-- termcolors = {} -- table of colour name strings
},
playground = {
enable = true,
disable = {},
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
persist_queries = false, -- Whether the query persists across vim sessions
keybindings = {
toggle_query_editor = 'o',
toggle_hl_groups = 'i',
toggle_injected_languages = 't',
toggle_anonymous_nodes = 'a',
toggle_language_display = 'I',
focus_language = 'f',
unfocus_language = 'F',
update = 'R',
goto_node = '<cr>',
show_help = '?',
},
}
}
-- setting up tokyonight config
require("tokyonight").setup({
style = "night", -- The theme comes in three styles, `storm`, a darker variant `night` and `day`
transparent = false, -- Enable this to disable setting the background color
terminal_colors = true, -- Configure the colors used when opening a `:terminal` in Neovim
styles = {
-- Style to be applied to different syntax groups
-- Value is any valid attr-list value :help nvim_set_hl`
comments = {italic = false},
keywords = {italic = false},
functions = {},
variables = {},
-- Background styles. Can be "dark", "transparent" or "normal"
sidebars = "dark", -- style for sidebars, see below
floats = "dark", -- style for floating windows
},
sidebars = { "qf", "help" }, -- Set a darker background on sidebar-like windows.
--For example: `["qf", "vista_kind", "terminal", "packer"]`
-- Adjusts the brightness of the colors of the **Day** style. Number betwen 0 and 1, from dull to vibrant colors
day_brightness = 0.3,
-- Enabling this option, will hide inactive statuslines and replace them with a thin border instead.
-- Should work with the standard **StatusLine** and **LuaLine**.
hide_inactive_statusline = false,
dim_inactive = false, -- dims inactive windows
lualine_bold = false, -- When `true`, section headers in the lualine theme will be bold
--- You can override specific color groups to use other groups or a hex color
--- fucntion will be called with a ColorScheme table
---@param colors ColorScheme
on_colors = function(colors) end,
--- You can override specific highlights to use other groups or a hex color
--- fucntion will be called with a Highlights and ColorScheme table
---@param highlights Highlights
---@param colors ColorScheme
on_highlights = function(highlights, colors) end,
})
-- Telescope config setup
require('telescope').setup(
{ defaults = { layout_config = {
horizontal = { preview_width = 0.65 } } }
}
)
-- nvim-web-devicons setup
require'nvim-web-devicons'.setup{
default = true;
}
-- setting up pyright
require'lspconfig'.pyright.setup{}
-- setting up Pylsp
require'lspconfig'.pylsp.setup{}
-- setting up Marksman
require'lspconfig'.marksman.setup{
}
-- setting up html
require'lspconfig'.html.setup{}
-- setting up css
require'lspconfig'.cssls.setup{}
-- setting up typescript
require'lspconfig'.tsserver.setup{}
-- setting up clangd
require'lspconfig'.clangd.setup{}
-- setting up LuaSnip
local luasnip = require 'luasnip'
vim.cmd[[colorscheme tokyonight]]
vim.api.nvim_set_hl(0, '@variable', {fg = "#7cb2dd" })
-- setting up bufferline
vim.opt.termguicolors = true
require("bufferline").setup{}
vim.cmd[[
nnoremap <silent><TAB> :BufferLineCycleNext<CR>
nnoremap <silent><S-TAB> :BufferLineCyclePrev<CR>
]]
-- configuring buffer close keybind
vim.cmd('nnoremap bq :bdelete<CR>')
-- configuring nvim-tree-kyazdani
vim.cmd('nnoremap <space>e :NvimTreeToggle<CR>')
-- configuring nvim-zen-mode keybinding
vim.cmd('nnoremap <space>z :ZenMode<CR>')
-- configuring markdown-preview keybinding
vim.cmd('nnoremap md :MarkdownPreview<CR>')
-- disable lsp warning messages and signs
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
vim.lsp.diagnostic.on_publish_diagnostics, {
signs = false,
virtual_text = false,
underline = false,
update_in_insert = false,
}
)
-- toggle term config
require("toggleterm").setup{
-- size can be a number or function which is passed the current terminal
size = 20,
open_mapping = [[<c-t>]],
hide_numbers = true, -- hide the number column in toggleterm buffers
shade_filetypes = {},
highlights = {
border = "Normal",
background = "Normal"},
shade_terminals = true, -- NOTE: this option takes priority over highlights specified so if you specify Normal highlights you should set this to false
shading_factor = 2, -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
start_in_insert = true,
insert_mappings = true, -- whether or not the open mapping applies in insert mode
--terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
persist_size = true,
-- persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered
direction = 'float',
close_on_exit = true, -- close the terminal window when the process exits
shell = vim.o.shell, -- change the default shell
--auto_scroll = true, -- automatically scroll to the bottom on terminal output
-- This field is only relevant if direction is set to 'float'
float_opts = {
border = 'curved',
winblend = 3,
},
}
-- comment setup
require('Comment').setup()
-- lualine setup
require('lualine').setup()
-- mason setup
require("mason").setup()