init.lua

my config
mail@pastecode.io avatar
unknown
lua
7 months ago
6.1 kB
1
Indexable
Never
------------------------
-- Require statements --
------------------------
require("core.options") --> options from lua/core/options.lua
require("core.keymaps") --> keymaps from lua/core/keymaps.lua

---------------------
-- Installing Lazy --
---------------------
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)

-------------
-- Plugins --
-------------

require("lazy").setup({
  -- Catppuccin colorscheme 
  {
    "catppuccin/nvim",
    name = "catppuccin",
    priority = 1000,
    config = function()
      vim.cmd.colorscheme 'catppuccin'
    end,
  },

  -- Lualine as a status line 
  {
    'nvim-lualine/lualine.nvim',
    dependencies = {
      'nvim-tree/nvim-web-devicons',
    },
		-- cheakout :help lualine.txt for info
    opts = {
      options = {
				disabled_filetypes = { 'NvimTree' },
        icons_enabled = true,
        theme = 'catppuccin',
        section_separators = { left = '', right = '' },
        component_separators = { left = '', right = ''},
      },
      sections = {
        lualine_a = {
          { icon = '', 'mode', separator = { left = '' , right = ''}, right_padding = 2 },
        },
        lualine_b = { 
					{ 'filetype', icon_only = true }, 
					{ 'filename' , color = { fg = '#bcc0cc' } },
					'branch' 
				},
        lualine_c = { 'fileformat' },
        lualine_x = {},
        lualine_y = { { 'filetype' , color = { fg = '#bcc0cc' } }, 'progress' },
        lualine_z = {
          { 'location', separator = { right = '' }, left_padding = 2 },
        },
      },
    },
  },

  -- Indent blankline
  { "lukas-reineke/indent-blankline.nvim", main = "ibl", opts = {} },

	-- Telescope fuzzy finder
  {
    'nvim-telescope/telescope.nvim',
    dependencies = { 
			'nvim-lua/plenary.nvim',
		},
		config = function()
      local telescope = require("telescope")
      local actions = require("telescope.actions")
      telescope.setup({
		    defaults = {
          mappings = {
            i = {
              ['<C-j>'] = actions.move_selection_next,
              ['<C-k>'] = actions.move_selection_previous,
            },
          },
        },
		  })
		end,
  },

	-- Nvim filetree
	{
		'nvim-tree/nvim-tree.lua',
		config = function()
      -- disable netrw 
      vim.g.loaded_netrw = 1
      vim.g.loaded_netrwPlugin = 1
			-- setup function
			require("nvim-tree").setup()
		end,
	},

	-- Toggle terminal 
	{
		'akinsho/toggleterm.nvim',
	   config = function()
			require("toggleterm").setup({
			  open_mapping = [[<c-t>]],
				direction = 'float',
			  float_opts = {
					border = 'curved',
					winblend = 0,
					highlights = {
						border = 'Normal',
						background = 'Normal',
					},
				},
			 })
		 end,
	},

	 -- Vim navigator
	{
	  'christoomey/vim-tmux-navigator',
	},

	 -- Buffer line 
	{
	  'akinsho/bufferline.nvim',
	  version = "*", 
		dependencies = 'nvim-tree/nvim-web-devicons',
		config = function()
			require("bufferline").setup({
			  options = {
				  indicator = { style = "icon", icon = ""},
          buffer_close_icon = '',
          modified_icon = "●",
          close_icon = "",
          left_trunc_marker = "",
          right_trunc_marker = "",
					offsets = { { filetype = "NvimTree", text = "  󰉋   File Explorer", text_align = "left" } },
			    max_name_length = 30,
          max_prefix_length = 30, -- prefix used when a buffer is de-duplicated
          tab_size = 20,
				}
			})
		 end,
	},

	  -- cmp plugins
	{ 
		"hrsh7th/nvim-cmp",
		config = function ()
			require("cmp").setup({
				sources = {
					name = 'buffer',
					option = {
					  keyword_pattern = [[\k\+]],
					},
				},
			})
		end,
	}, -- The completion plugin
	{ "hrsh7th/cmp-buffer" }, -- buffer completions
	{ "hrsh7th/cmp-path" }, -- path completions
	{ "hrsh7th/cmp-cmdline" }, -- cmdline completions
	{ 'hrsh7th/cmp-nvim-lsp' },

  -- snippets
	{ "L3MON4D3/LuaSnip" }, --snippet engine
	{ "rafamadriz/friendly-snippets" }, -- a bunch of snippets to use
	{ "saadparwaiz1/cmp_luasnip" }, -- snippet completions

	-- lsp config
	{ 'neovim/nvim-lspconfig' },

 	{ 
		'williamboman/mason.nvim' ,
		config = function()
			require("mason").setup({
				ui = {
					icons = {
            package_pending = " ",
            package_installed = "󰄳 ",
            package_uninstalled = " 󰚌",
					},
				},
			})
		end,
	},

	{ 
		'williamboman/mason-lspconfig.nvim' ,
		config = function()
			require("mason-lspconfig").setup({
	      ensure_installed = {
		      "html",
		      "cssls",
		      "tsserver",
	      }
      })
		end,
	},

})

-- [[ Configure nvim-cmp ]]

local cmp = require 'cmp'
local luasnip = require 'luasnip'
require('luasnip.loaders.from_vscode').lazy_load()
luasnip.config.setup {}

cmp.setup {
  snippet = {
    expand = function(args)
      luasnip.lsp_expand(args.body)
    end,
  },
  completion = {
    completeopt = 'menu,menuone,noinsert'
  },
  mapping = cmp.mapping.preset.insert {
    ['<C-n>'] = cmp.mapping.select_next_item(),
    ['<C-p>'] = cmp.mapping.select_prev_item(),
    ['<C-d>'] = cmp.mapping.scroll_docs(-4),
    ['<C-f>'] = cmp.mapping.scroll_docs(4),
    ['<C-Space>'] = cmp.mapping.complete {},
    ['<CR>'] = cmp.mapping.confirm {
      behavior = cmp.ConfirmBehavior.Replace,
      select = true,
    },
    ['<Tab>'] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_next_item()
      elseif luasnip.expand_or_locally_jumpable() then
        luasnip.expand_or_jump()
      else
        fallback()
      end
    end, { 'i', 's' }),
    ['<S-Tab>'] = cmp.mapping(function(fallback)
      if cmp.visible() then
        cmp.select_prev_item()
      elseif luasnip.locally_jumpable(-1) then
        luasnip.jump(-1)
      else
        fallback()
      end
    end, { 'i', 's' }),
  },
  sources = {
    { name = 'nvim_lsp' },
    { name = 'luasnip' },
  },
}
Leave a Comment