-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
222 lines (194 loc) · 5.6 KB
/
init.lua
File metadata and controls
222 lines (194 loc) · 5.6 KB
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
vim.o.number = true --line numbers
vim.o.relativenumber = false
vim.o.expandtab = true -- expand \t into spaces
vim.o.smartindent = true
vim.o.tabstop = 2 --number of spaces for a tab
vim.o.shiftwidth = 2
vim.opt.termguicolors = true
vim.cmd('syntax enable')
vim.cmd('filetype plugin indent on')
vim.g.mapleader = ' '
vim.api.nvim_set_keymap('n', '<Leader>w', ':w<CR>', { noremap = true, silent = true })
-- Bootstrap packer if it isn't installed
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
-- Autocommand that reloads neovim whenever you save the init.lua file
vim.cmd [[
augroup packer_user_config
autocmd!
autocmd BufWritePost init.lua source <afile> | PackerSync
augroup end
]]
-- plugins --
require('packer').startup(function(use)
use 'wbthomason/packer.nvim' -- Packer manages itself
-- Plugin examples
use {
'nvim-treesitter/nvim-treesitter',
run = ':TSUpdate'
}
use {
'nvim-tree/nvim-tree.lua',
requires = {
'nvim-tree/nvim-web-devicons',
},
}
use {
'nvim-telescope/telescope.nvim',
tag = '0.1.8',
requires = {
'nvim-lua/plenary.nvim',
},
}
-- auto pair for {}, (), etc.
use { 'windwp/nvim-autopairs',
event = 'InsertEnter',
config = function()
require('nvim-autopairs').setup {}
end
}
-- nvim-cmp main plugin
use { 'hrsh7th/nvim-cmp' }
-- nvim-cmp completion sources
use { 'hrsh7th/cmp-buffer' } -- Buffer completions
use { 'hrsh7th/cmp-path' } -- Path completions
use { 'hrsh7th/cmp-nvim-lsp' } -- LSP completions
use { 'hrsh7th/cmp-nvim-lua' } -- Lua API completions (useful for neovim config)
use { 'saadparwaiz1/cmp_luasnip' } -- Snippet completions
-- Snippet engine (luasnip)
use { 'L3MON4D3/LuaSnip' } -- Snippet engine
-- LSP Support (if not already set up)
use { 'neovim/nvim-lspconfig' } -- LSP configuration
use { 'catppuccin/nvim', as = 'catppuccin' } -- theme
if packer_bootstrap then
require('packer').sync()
end
end)
require'nvim-treesitter.configs'.setup {
ensure_installed = "all", -- or specify languages
highlight = {
enable = true,
},
}
-- recommended settings from the nvim-tree documentation
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
width = 30,
},
renderer = {
group_empty = true,
},
filters = {
dotfiles = true,
},
})
require('telescope').setup{
defaults = {
-- Default configuration for Telescope goes here:
vimgrep_arguments = {
'rg',
'--color=never',
'--no-heading',
'--with-filename',
'--line-number',
'--column',
'--smart-case'
},
prompt_position = "bottom",
prompt_prefix = "> ",
sorting_strategy = "ascending",
layout_config = {
horizontal = {
preview_width = 0.55,
results_width = 0.8,
},
},
},
}
-- Setup nvim-cmp for autocompletion
local cmp = require('cmp')
cmp.setup({
snippet = {
-- Specify the snippet engine (luasnip in this case)
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = {
['<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
['<Tab>'] = cmp.mapping.select_next_item(), -- Navigate to next item
['<S-Tab>'] = cmp.mapping.select_prev_item(), -- Navigate to previous item
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' }, -- LSP completions
{ name = 'luasnip' }, -- Snippet completions
{ name = 'buffer' }, -- Buffer completions
{ name = 'path' }, -- Path completions
})
})
-- LSP setup for nvim-cmp
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- python (pyright)
require('lspconfig')['pyright'].setup {
capabilities = capabilities,
}
-- c, c++ (clangd)
require('lspconfig').clangd.setup {
capabilities = capabilities,
cmd = {'clangd'},
}
-- JS - ts server
-- ... todo
-- Load and apply Catppuccin
require("catppuccin").setup({
flavour = "mocha", -- latte, frappe, macchiato, mocha (Choose your favorite variant)
transparent_background = false, -- Enable/disable transparent background
term_colors = true, -- Enable terminal colors
integrations = {
treesitter = true,
native_lsp = {
enabled = true,
virtual_text = {
errors = { "italic" },
hints = { "italic" },
warnings = { "italic" },
information = { "italic" },
},
},
lsp_trouble = true,
cmp = true,
gitsigns = true,
telescope = true,
nvimtree = {
enabled = true,
show_root = true,
transparent_panel = false,
},
which_key = true,
indent_blankline = {
enabled = true,
colored_indent_levels = false,
},
}
})
-- Set the colorscheme to catppuccin
vim.cmd.colorscheme "catppuccin"
-- key bindings --
vim.api.nvim_set_keymap('n', '<leader>sf', ":lua require('telescope.builtin').find_files()<CR>", { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sg', ":lua require('telescope.builtin').live_grep()<CR>", { noremap = true, silent = true })