summaryrefslogtreecommitdiff
path: root/.config/nvim/init.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/init.lua')
-rw-r--r--.config/nvim/init.lua172
1 files changed, 168 insertions, 4 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua
index 732ea40..f140d6a 100644
--- a/.config/nvim/init.lua
+++ b/.config/nvim/init.lua
@@ -20,13 +20,177 @@ vim.opt.cino = ":0l1(0"
vim.opt.signcolumn = "yes" -- LSP diagnostics
vim.opt.termguicolors = true -- enable true colors
vim.opt.completeopt = { "menu", "menuone", "noselect" } -- required for nvim-cmp
-
--- plugin manager (set leader key before loading lazy.nvim)
vim.g.mapleader = " " -- Set leader to space
vim.g.maplocalleader = "\\" -- Set local leader to backslash
-require("config.lazy")
--- load lsp's
+
+-- keymap
+vim.keymap.set('n', '<leader>gd', vim.lsp.buf.definition, { desc = 'Go to definition' })
+
+
+-- packages
+-- Todo: telescope
+-- Todo: finish https://github.com/hrsh7th/nvim-cmp
+vim.pack.add({
+ { src = 'https://github.com/sainnhe/gruvbox-material' },
+
+ { src = 'https://github.com/nvim-tree/nvim-web-devicons' },
+ { src = 'https://github.com/nvim-lualine/lualine.nvim' },
+
+ { src = 'https://github.com/nvim-treesitter/nvim-treesitter', version = 'main' },
+ { src = 'https://github.com/neovim/nvim-lspconfig' },
+
+ { src = 'https://github.com/hrsh7th/cmp-nvim-lsp' },
+ { src = 'https://github.com/hrsh7th/cmp-buffer' },
+ { src = 'https://github.com/hrsh7th/cmp-path' },
+ { src = 'https://github.com/hrsh7th/cmp-cmdline' },
+ { src = 'https://github.com/hrsh7th/nvim-cmp' },
+ { src = 'https://github.com/hrsh7th/cmp-vsnip' },
+ { src = 'https://github.com/hrsh7th/vim-vsnip' },
+
+ { src = 'https://github.com/lervag/vimtex' },
+})
+
+
+
+-- init plugin gruvbox-material
+vim.g.gruvbox_material_background = 'hard'
+vim.g.gruvbox_material_foreground = 'material'
+vim.g.gruvbox_material_enable_italic = true
+vim.g.gruvbox_material_disable_italic_comment = false
+vim.g.gruvbox_material_better_performance = 1
+vim.cmd.colorscheme('gruvbox-material')
+
+
+-- init plugin lualine
+require('lualine').setup {
+ options = {
+ icons_enabled = true,
+ theme = 'auto',
+ component_separators = { left = '', right = ''},
+ section_separators = { left = '', right = ''},
+ disabled_filetypes = {
+ statusline = {},
+ winbar = {},
+ },
+ ignore_focus = {},
+ always_divide_middle = true,
+ always_show_tabline = true,
+ globalstatus = false,
+ refresh = {
+ statusline = 1000,
+ tabline = 1000,
+ winbar = 1000,
+ refresh_time = 16, -- ~60fps
+ events = {
+ 'WinEnter',
+ 'BufEnter',
+ 'BufWritePost',
+ 'SessionLoadPost',
+ 'FileChangedShellPost',
+ 'VimResized',
+ 'Filetype',
+ 'CursorMoved',
+ 'CursorMovedI',
+ 'ModeChanged',
+ },
+ }
+ },
+ sections = {
+ lualine_a = {'mode'},
+ lualine_b = {'branch', 'diff', 'diagnostics'},
+ lualine_c = {'filename'},
+ lualine_x = {'encoding', 'fileformat', 'filetype'},
+ lualine_y = {'progress'},
+ lualine_z = {'location'}
+ },
+ inactive_sections = {
+ lualine_a = {},
+ lualine_b = {},
+ lualine_c = {'filename'},
+ lualine_x = {'location'},
+ lualine_y = {},
+ lualine_z = {}
+ },
+ tabline = {},
+ winbar = {},
+ inactive_winbar = {},
+ extensions = {}
+}
+
+
+-- cmp
+local cmp = require("cmp")
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ end,
+ },
+ window = {
+ -- completion = cmp.config.window.bordered(),
+ -- documentation = cmp.config.window.bordered(),
+ },
+ 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' },
+ }, {
+ { name = 'buffer' },
+ })
+})
+
+-- Use buffer source for `/` and `?` (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' }
+ }),
+ matching = { disallow_symbol_nonprefix_matching = false }
+})
+
+
+-- treesitter
+require'nvim-treesitter'.install { 'cpp' }
+
+
+-- vimtex
+require('lualine').setup {
+ ft = { "tex", "bib" },
+ dependencies = { "nvim-treesitter/nvim-treesitter" },
+ config = function()
+ vim.g.vimtex_view_method = "mupdf"
+ end
+}
+
+
+-- lsp
+vim.lsp.config('lua_ls', {
+ capabilities = capabilities
+})
+vim.lsp.config('clangd', {
+ capabilities = capabilities
+})
+vim.lsp.config('pyright', {
+ capabilities = capabilities
+})
+
vim.lsp.enable({
'lua_ls',
'clangd',