Advertisement
Guest User

init.lua

a guest
Mar 10th, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.25 KB | None | 0 0
  1. -- [[defaults]]
  2. local leader_key = " "
  3. local tab_length = 2
  4.  
  5.  
  6. -- [[setting defaults]]
  7. vim.g.mapleader = leader_key
  8. vim.opt.tabstop = tab_length
  9. vim.opt.shiftwidth = tab_length
  10. vim.opt.softtabstop = tab_length
  11. vim.opt.autoindent = true
  12. vim.opt.expandtab = true
  13. vim.opt.relativenumber = true
  14.  
  15.  
  16. -- [[plugins: lazy.nvim]]
  17. local plugins = {
  18.   {
  19.     "AstroNvim/astrotheme",
  20.     priority = 1000
  21.   },
  22.   {
  23.     'nvim-telescope/telescope.nvim', tag = '0.1.5',
  24.     dependencies = { 'nvim-lua/plenary.nvim' }
  25.   },
  26.   {
  27.     "nvim-treesitter/nvim-treesitter",
  28.     build = ":TSUpdate"
  29.   },
  30.   {
  31.     "williamboman/mason.nvim",
  32.     "williamboman/mason-lspconfig.nvim",
  33.     "neovim/nvim-lspconfig",
  34.   },
  35.   {
  36.     'windwp/nvim-autopairs',
  37.     event = "InsertEnter",
  38.     config = true
  39.   },
  40.   {
  41.     'VonHeikemen/lsp-zero.nvim',
  42.     branch = 'v3.x'
  43.   },
  44.   {
  45.     'neovim/nvim-lspconfig'
  46.   },
  47.   {
  48.     'hrsh7th/cmp-nvim-lsp'
  49.   },
  50.   {
  51.     'hrsh7th/nvim-cmp'
  52.   },
  53.   {
  54.     'L3MON4D3/LuaSnip'
  55.   },
  56.   {
  57.     'numToStr/Comment.nvim',
  58.     opts = {
  59.       -- add any options here
  60.     },
  61.     lazy = false,
  62.   },
  63.   {
  64.     'lewis6991/gitsigns.nvim',
  65.     opts = {
  66.       signs = {
  67.         add = { text = '+' },
  68.         change = { text = '~' },
  69.         delete = { text = '_' },
  70.         topdelete = { text = '‾' },
  71.         changedelete = { text = '~' },
  72.       },
  73.     },
  74.   },
  75.   {
  76.     'goolord/alpha-nvim',
  77.   },
  78. }
  79.  
  80. local opts = {}
  81.  
  82.  
  83. -- [[lazy: package manager]]
  84. -- ref: https://github.com/folke/lazy.nvim
  85. local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
  86.  
  87. if not vim.loop.fs_stat(lazypath) then
  88.   vim.fn.system({
  89.     "git",
  90.     "clone",
  91.     "--filter=blob:none",
  92.     "https://github.com/folke/lazy.nvim.git",
  93.     "--branch=stable", -- latest stable release
  94.     lazypath,
  95.   })
  96. end
  97.  
  98. vim.opt.rtp:prepend(lazypath)
  99. require("lazy").setup(plugins, opts) -- plugins, opts are defined at the top
  100.  
  101.  
  102. -- [[astrotheme: colorscheme]]
  103. -- ref: https://github.com/AstroNvim/astrotheme
  104. require("astrotheme").setup()
  105. vim.cmd.colorscheme "astrodark"
  106.  
  107.  
  108. -- [[telescope: file/dir browser]]
  109. -- ref: https://github.com/nvim-telescope/telescope.nvim
  110. local builtin = require('telescope.builtin')
  111. vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
  112. vim.keymap.set('n', '<leader>ft', builtin.live_grep, {})
  113. vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
  114. vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
  115.  
  116.  
  117. -- [[treesitter: syntax highlighting]]
  118. -- ref: https://github.com/nvim-treesitter/nvim-treesitter
  119. local configs = require("nvim-treesitter.configs")
  120.  
  121. configs.setup({
  122.   ensure_installed = { "c", "cpp", "python", "lua" },
  123.   sync_install = false,
  124.   highlight = { enable = true },
  125.   indent = { enable = true },  
  126. })
  127.  
  128.  
  129. -- [[lsp zero: lsp]]
  130. -- ref: https://github.com/VonHeikemen/lsp-zero.nvim
  131. local lsp_zero = require('lsp-zero')
  132.  
  133. lsp_zero.on_attach(function(client, bufnr)
  134.   -- see :help lsp-zero-keybindings
  135.   lsp_zero.default_keymaps({buffer = bufnr})
  136. end)
  137.  
  138.  
  139. -- [[mason: lsp + dep for lsp zero]]
  140. -- ref: https://github.com/williamboman/mason.nvim
  141. require('mason').setup({})
  142. require('mason-lspconfig').setup({
  143.   ensure_installed = {},
  144.   handlers = {
  145.     lsp_zero.default_setup,
  146.   },
  147. })
  148.  
  149.  
  150. -- [[autopairs: for brackets]]
  151. -- ref: https://github.com/windwp/nvim-autopairs
  152. require('nvim-autopairs').setup({
  153.   disable_filetype = { "TelescopePrompt" , "vim" },
  154. })
  155.  
  156.  
  157. -- [[Comment.nvim: for comments]]
  158. -- ref: https://github.com/numToStr/Comment.nvim
  159. require('Comment').setup()
  160.  
  161.  
  162. -- [[gitsings: for git]]
  163. -- ref: https://github.com/lewis6991/gitsigns.nvim
  164. require('gitsigns').setup()
  165.  
  166.  
  167. -- [[alpha: startup screen]]
  168. -- ref: https://github.com/goolord/alpha-nvim
  169. require('alpha').setup(require('alpha.themes.dashboard').config)
  170.  
  171.  
  172. -- [[sync clipboard: for wsl]]
  173. -- ref: https://www.reddit.com/r/neovim/comments/vxdjyb/neovim_in_wsl2_cant_copypaste_tofrom_system/
  174. vim.opt.clipboard = "unnamedplus"
  175.  
  176. if vim.fn.has("wsl") == 1 then
  177.   vim.g.clipboard = {
  178.     name = "win32yank-wsl",
  179.     copy = {
  180.       ["+"] = "win32yank.exe -i --crlf",
  181.       ["*"] = "win32yank.exe -i --crlf",
  182.     },
  183.     paste = {
  184.       ["+"] = "win32yank.exe -o --lf",
  185.       ["*"] = "win32yank.exe -o --lf",
  186.     },
  187.     cache_enabled = 0,
  188.   }
  189. end
  190.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement