feat: initial setup
This commit is contained in:
		
							
								
								
									
										10
									
								
								lua/autocmd.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								lua/autocmd.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufEnter, BufWinEnter" },
 | 
			
		||||
  { command = "set colorcolumn=120,80,88", pattern = { "*.py", "*.pyi" } })
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufEnter, BufWinEnter" },
 | 
			
		||||
  { command = "set colorcolumn=80,100", pattern = { "*.rs" } })
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufEnter, BufWinEnter" },
 | 
			
		||||
  { command = "set splitright", pattern = { "*" } })
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufEnter, BufWinEnter" },
 | 
			
		||||
  { command = "set splitbelow", pattern = { "*" } })
 | 
			
		||||
 | 
			
		||||
return {}
 | 
			
		||||
							
								
								
									
										49
									
								
								lua/keymaps.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								lua/keymaps.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
-- [[ Basic Keymaps ]]
 | 
			
		||||
 | 
			
		||||
-- Keymaps for better default experience
 | 
			
		||||
-- See `:help vim.keymap.set()`
 | 
			
		||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
 | 
			
		||||
 | 
			
		||||
-- Remap for dealing with word wrap
 | 
			
		||||
vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
 | 
			
		||||
vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
 | 
			
		||||
 | 
			
		||||
-- Remap for vertical navigation
 | 
			
		||||
vim.keymap.set('n', '<C-d>', '<C-d>zz', { noremap = true, silent = true })
 | 
			
		||||
vim.keymap.set('n', '<C-u>', '<C-u>zz', { noremap = true, silent = true })
 | 
			
		||||
vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, silent = true })
 | 
			
		||||
vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true, silent = true })
 | 
			
		||||
 | 
			
		||||
-- [[ Highlight on yank ]]
 | 
			
		||||
-- See `:help vim.highlight.on_yank()`
 | 
			
		||||
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true })
 | 
			
		||||
vim.api.nvim_create_autocmd('TextYankPost', {
 | 
			
		||||
  callback = function()
 | 
			
		||||
    vim.highlight.on_yank()
 | 
			
		||||
  end,
 | 
			
		||||
  group = highlight_group,
 | 
			
		||||
  pattern = '*',
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- Diagnostic keymaps
 | 
			
		||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
 | 
			
		||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
 | 
			
		||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
 | 
			
		||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist)
 | 
			
		||||
 | 
			
		||||
-- terminal keymaps
 | 
			
		||||
function _G.set_terminal_keymaps()
 | 
			
		||||
  local opts = { buffer = 0 }
 | 
			
		||||
  vim.keymap.set('t', '<esc>', [[<C-\><C-n>]], opts)
 | 
			
		||||
  vim.keymap.set('t', '<C-h>', [[<Cmd>wincmd h<CR>]], opts)
 | 
			
		||||
  vim.keymap.set('t', '<C-j>', [[<Cmd>wincmd j<CR>]], opts)
 | 
			
		||||
  vim.keymap.set('t', '<C-k>', [[<Cmd>wincmd k<CR>]], opts)
 | 
			
		||||
  vim.keymap.set('t', '<C-l>', [[<Cmd>wincmd l<CR>]], opts)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
--
 | 
			
		||||
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
 | 
			
		||||
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
return {}
 | 
			
		||||
							
								
								
									
										47
									
								
								lua/options.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								lua/options.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
-- [[ Setting options ]]
 | 
			
		||||
-- See `:help vim.o`
 | 
			
		||||
 | 
			
		||||
-- Set highlight on search
 | 
			
		||||
vim.o.hlsearch = false
 | 
			
		||||
 | 
			
		||||
-- Make line numbers default
 | 
			
		||||
vim.wo.number = true
 | 
			
		||||
 | 
			
		||||
-- Make line numbers relative
 | 
			
		||||
vim.wo.relativenumber = true
 | 
			
		||||
 | 
			
		||||
-- Enable mouse mode
 | 
			
		||||
vim.o.mouse = 'a'
 | 
			
		||||
 | 
			
		||||
-- Sync clipboard between OS and Neovim.
 | 
			
		||||
--  Remove this option if you want your OS clipboard to remain independent.
 | 
			
		||||
--  See `:help 'clipboard'`
 | 
			
		||||
vim.o.clipboard = 'unnamedplus'
 | 
			
		||||
 | 
			
		||||
-- Enable break indent
 | 
			
		||||
vim.o.breakindent = true
 | 
			
		||||
 | 
			
		||||
-- Save undo history
 | 
			
		||||
vim.o.undofile = true
 | 
			
		||||
 | 
			
		||||
-- Case insensitive searching UNLESS /C or capital in search
 | 
			
		||||
vim.o.ignorecase = true
 | 
			
		||||
vim.o.smartcase = true
 | 
			
		||||
 | 
			
		||||
-- Keep signcolumn on by default
 | 
			
		||||
vim.wo.signcolumn = 'yes'
 | 
			
		||||
 | 
			
		||||
-- Decrease update time
 | 
			
		||||
vim.o.updatetime = 250
 | 
			
		||||
vim.o.timeout = true
 | 
			
		||||
vim.o.timeoutlen = 300
 | 
			
		||||
 | 
			
		||||
-- Set completeopt to have a better completion experience
 | 
			
		||||
vim.o.completeopt = 'menuone,noselect'
 | 
			
		||||
 | 
			
		||||
vim.o.termguicolors = true
 | 
			
		||||
 | 
			
		||||
-- set custom end of line character
 | 
			
		||||
vim.cmd [[set list listchars=eol:]]
 | 
			
		||||
 | 
			
		||||
return {}
 | 
			
		||||
							
								
								
									
										70
									
								
								lua/plugins/cmp.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								lua/plugins/cmp.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
			
		||||
function leave_snippet()
 | 
			
		||||
  if ((vim.v.event.old_mode == 's' and vim.v.event.new_mode == 'n') or vim.v.event.old_mode == 'i')
 | 
			
		||||
      and require('luasnip').session.current_nodes[vim.api.nvim_get_current_buf()]
 | 
			
		||||
      and not require('luasnip').session.jump_active
 | 
			
		||||
  then
 | 
			
		||||
    require('luasnip').unlink_current()
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
vim.api.nvim_command([[
 | 
			
		||||
    autocmd ModeChanged * lua leave_snippet()
 | 
			
		||||
]])
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
  {
 | 
			
		||||
    'hrsh7th/nvim-cmp',
 | 
			
		||||
    dependencies = {
 | 
			
		||||
      'hrsh7th/cmp-nvim-lsp',
 | 
			
		||||
      'L3MON4D3/LuaSnip',
 | 
			
		||||
      'saadparwaiz1/cmp_luasnip'
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    config = function ()
 | 
			
		||||
      -- nvim-cmp setup
 | 
			
		||||
      local cmp = require 'cmp'
 | 
			
		||||
      local luasnip = require 'luasnip'
 | 
			
		||||
 | 
			
		||||
      luasnip.config.setup {}
 | 
			
		||||
 | 
			
		||||
      cmp.setup {
 | 
			
		||||
        snippet = {
 | 
			
		||||
          expand = function(args)
 | 
			
		||||
            luasnip.lsp_expand(args.body)
 | 
			
		||||
          end,
 | 
			
		||||
        },
 | 
			
		||||
        mapping = cmp.mapping.preset.insert {
 | 
			
		||||
          ['<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_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.jumpable(-1) then
 | 
			
		||||
              luasnip.jump(-1)
 | 
			
		||||
            else
 | 
			
		||||
              fallback()
 | 
			
		||||
            end
 | 
			
		||||
          end, { 'i', 's' }),
 | 
			
		||||
        },
 | 
			
		||||
        sources = {
 | 
			
		||||
          { name = 'nvim_lsp' },
 | 
			
		||||
          { name = 'luasnip' },
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										119
									
								
								lua/plugins/common.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								lua/plugins/common.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,119 @@
 | 
			
		||||
return {
 | 
			
		||||
  -- NOTE: First, some plugins that don't require any configuration
 | 
			
		||||
 | 
			
		||||
  -- Git related plugins
 | 
			
		||||
  'tpope/vim-fugitive',
 | 
			
		||||
  'tpope/vim-rhubarb',
 | 
			
		||||
 | 
			
		||||
  -- Detect tabstop and shiftwidth automatically
 | 
			
		||||
  'tpope/vim-sleuth',
 | 
			
		||||
 | 
			
		||||
  -- NOTE: Second, plugins that require setup call
 | 
			
		||||
 | 
			
		||||
  -- Useful plugin to show you pending keybinds.
 | 
			
		||||
  { 'folke/which-key.nvim',        opts = {} },
 | 
			
		||||
 | 
			
		||||
  -- "gc" to comment visual regions/lines
 | 
			
		||||
  { 'numToStr/Comment.nvim',       opts = {} },
 | 
			
		||||
 | 
			
		||||
  -- colorize in files
 | 
			
		||||
  { "norcalli/nvim-colorizer.lua", opts = {} },
 | 
			
		||||
 | 
			
		||||
  -- highlighting for comments
 | 
			
		||||
  { "folke/todo-comments.nvim",    dependencies = "nvim-lua/plenary.nvim", opts = {} },
 | 
			
		||||
 | 
			
		||||
  -- NOTE: Third, plugins that require some setup, but not enugh for separate file
 | 
			
		||||
 | 
			
		||||
  { -- Adds git releated signs to the gutter, as well as utilities for managing changes
 | 
			
		||||
    'lewis6991/gitsigns.nvim',
 | 
			
		||||
    opts = {
 | 
			
		||||
      -- See `:help gitsigns.txt`
 | 
			
		||||
      signs = {
 | 
			
		||||
        add = { text = '+' },
 | 
			
		||||
        change = { text = '~' },
 | 
			
		||||
        delete = { text = '_' },
 | 
			
		||||
        topdelete = { text = '‾' },
 | 
			
		||||
        changedelete = { text = '~' },
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  { -- Set lualine as statusline
 | 
			
		||||
    'nvim-lualine/lualine.nvim',
 | 
			
		||||
    -- See `:help lualine.txt`
 | 
			
		||||
    opts = {
 | 
			
		||||
      options = {
 | 
			
		||||
        icons_enabled = false,
 | 
			
		||||
        theme = 'onedark',
 | 
			
		||||
        component_separators = '|',
 | 
			
		||||
        section_separators = '',
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  { -- Add indentation guides even on blank lines
 | 
			
		||||
    'lukas-reineke/indent-blankline.nvim',
 | 
			
		||||
    -- Enable `lukas-reineke/indent-blankline.nvim`
 | 
			
		||||
    -- See `:help indent_blankline.txt`
 | 
			
		||||
    opts = {
 | 
			
		||||
      char = '┊',
 | 
			
		||||
      show_trailing_blankline_indent = false,
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  { -- git blame annotations
 | 
			
		||||
    'f-person/git-blame.nvim',
 | 
			
		||||
    config = function()
 | 
			
		||||
      vim.api.nvim_set_keymap('n', '<leader>gt', ':GitBlameToggle<CR>', { desc = '[G]it Blame [T]oggle', noremap = true })
 | 
			
		||||
      vim.api.nvim_set_keymap('n', '<leader>gu', ':GitBlameOpenCommitURL<CR>',
 | 
			
		||||
        { desc = '[G]it Blame Open Commit [U]rl', noremap = true })
 | 
			
		||||
    end
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  { -- a more adventurous wildmenu
 | 
			
		||||
    'gelguy/wilder.nvim',
 | 
			
		||||
 | 
			
		||||
    dependencies = { 'romgrk/fzy-lua-native' },
 | 
			
		||||
 | 
			
		||||
    config = function()
 | 
			
		||||
      local wilder = require('wilder')
 | 
			
		||||
      wilder.setup({ modes = { ':', '/', '?' } })
 | 
			
		||||
      -- Disable Python remote plugin
 | 
			
		||||
      wilder.set_option('use_python_remote_plugin', 0)
 | 
			
		||||
 | 
			
		||||
      wilder.set_option('pipeline', {
 | 
			
		||||
        wilder.branch(
 | 
			
		||||
          wilder.cmdline_pipeline({
 | 
			
		||||
            fuzzy = 1,
 | 
			
		||||
            fuzzy_filter = wilder.lua_fzy_filter(),
 | 
			
		||||
          }),
 | 
			
		||||
          wilder.vim_search_pipeline()
 | 
			
		||||
        )
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      wilder.set_option('renderer', wilder.popupmenu_renderer(
 | 
			
		||||
        wilder.popupmenu_border_theme({
 | 
			
		||||
          highlights = {
 | 
			
		||||
            border = 'Normal',
 | 
			
		||||
          },
 | 
			
		||||
          border = 'rounded',
 | 
			
		||||
          highlighter = wilder.lua_fzy_highlighter(),
 | 
			
		||||
          left = { ' ', wilder.popupmenu_devicons() },
 | 
			
		||||
          right = { ' ', wilder.popupmenu_scrollbar() },
 | 
			
		||||
        })
 | 
			
		||||
      ))
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  -- NOTE: Finally, themes
 | 
			
		||||
  -- FIX: figure out how to switch between themes more easily
 | 
			
		||||
 | 
			
		||||
  { -- Theme inspired by Atom
 | 
			
		||||
    'navarasu/onedark.nvim',
 | 
			
		||||
    priority = 1000,
 | 
			
		||||
    config = function()
 | 
			
		||||
      vim.cmd.colorscheme 'onedark'
 | 
			
		||||
    end,
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										144
									
								
								lua/plugins/lsp.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										144
									
								
								lua/plugins/lsp.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,144 @@
 | 
			
		||||
-- LSP settings.
 | 
			
		||||
--  This function gets run when an LSP connects to a particular buffer.
 | 
			
		||||
local on_attach = function(_, bufnr)
 | 
			
		||||
  -- NOTE: Remember that lua is a real programming language, and as such it is possible
 | 
			
		||||
  -- to define small helper and utility functions so you don't have to repeat yourself
 | 
			
		||||
  -- many times.
 | 
			
		||||
  --
 | 
			
		||||
  -- In this case, we create a function that lets us more easily define mappings specific
 | 
			
		||||
  -- for LSP related items. It sets the mode, buffer and description for us each time.
 | 
			
		||||
  local nmap = function(keys, func, desc)
 | 
			
		||||
    if desc then
 | 
			
		||||
      desc = 'LSP: ' .. desc
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  local delayed_format = function()
 | 
			
		||||
    vim.lsp.buf.format({ timeout_ms = 2000 })
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
 | 
			
		||||
  nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
 | 
			
		||||
  nmap('<leader>ff', delayed_format, '[F]ormat')
 | 
			
		||||
 | 
			
		||||
  nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition')
 | 
			
		||||
  nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
 | 
			
		||||
  nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation')
 | 
			
		||||
  nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
 | 
			
		||||
  nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
 | 
			
		||||
  nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
 | 
			
		||||
 | 
			
		||||
  -- See `:help K` for why this keymap
 | 
			
		||||
  nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
 | 
			
		||||
  nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
 | 
			
		||||
 | 
			
		||||
  -- Lesser used LSP functionality
 | 
			
		||||
  nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
 | 
			
		||||
  nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
 | 
			
		||||
  nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
 | 
			
		||||
  nmap('<leader>wl', function()
 | 
			
		||||
    print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
 | 
			
		||||
  end, '[W]orkspace [L]ist Folders')
 | 
			
		||||
 | 
			
		||||
  -- Create a command `:Format` local to the LSP buffer
 | 
			
		||||
  vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
 | 
			
		||||
    vim.lsp.buf.format()
 | 
			
		||||
  end, { desc = 'Format current buffer with LSP' })
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
  { -- LSP Configuration & Plugins
 | 
			
		||||
    'neovim/nvim-lspconfig',
 | 
			
		||||
    dependencies = {
 | 
			
		||||
      -- Automatically install LSPs to stdpath for neovim
 | 
			
		||||
      'williamboman/mason.nvim',
 | 
			
		||||
      'williamboman/mason-lspconfig.nvim',
 | 
			
		||||
 | 
			
		||||
      -- Useful status updates for LSP
 | 
			
		||||
      { 'j-hui/fidget.nvim', opts = {} },
 | 
			
		||||
 | 
			
		||||
      -- Additional lua configuration, makes nvim stuff amazing!
 | 
			
		||||
      'folke/neodev.nvim',
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    config = function ()
 | 
			
		||||
      local servers = {
 | 
			
		||||
        -- clangd = {},
 | 
			
		||||
        -- gopls = {},
 | 
			
		||||
        marksman = {},
 | 
			
		||||
        pyright = {},
 | 
			
		||||
        rust_analyzer = {
 | 
			
		||||
          checkOnSave = {
 | 
			
		||||
            allFeatures = true,
 | 
			
		||||
            overrideCommand = {
 | 
			
		||||
              'cargo', 'clippy', '--workspace', '--message-format=json',
 | 
			
		||||
              '--all-targets', '--all-features'
 | 
			
		||||
            }
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
        tsserver = {},
 | 
			
		||||
 | 
			
		||||
        lua_ls = {
 | 
			
		||||
          Lua = {
 | 
			
		||||
            workspace = { checkThirdParty = false },
 | 
			
		||||
            telemetry = { enable = false },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      -- Setup neovim lua configuration
 | 
			
		||||
      require('neodev').setup()
 | 
			
		||||
 | 
			
		||||
      -- nvim-cmp supports additional completion capabilities, so broadcast that to servers
 | 
			
		||||
      local capabilities = vim.lsp.protocol.make_client_capabilities()
 | 
			
		||||
      capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
 | 
			
		||||
 | 
			
		||||
      -- Setup mason so it can manage external tooling
 | 
			
		||||
      require('mason').setup()
 | 
			
		||||
 | 
			
		||||
      -- Ensure the servers above are installed
 | 
			
		||||
      local mason_lspconfig = require 'mason-lspconfig'
 | 
			
		||||
 | 
			
		||||
      mason_lspconfig.setup {
 | 
			
		||||
        ensure_installed = vim.tbl_keys(servers),
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      mason_lspconfig.setup_handlers {
 | 
			
		||||
        function(server_name)
 | 
			
		||||
          require('lspconfig')[server_name].setup {
 | 
			
		||||
            capabilities = capabilities,
 | 
			
		||||
            on_attach = on_attach,
 | 
			
		||||
            settings = servers[server_name],
 | 
			
		||||
          }
 | 
			
		||||
        end,
 | 
			
		||||
      }
 | 
			
		||||
    end
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  { -- inject lsp formatting, diagonstics etc
 | 
			
		||||
    'jose-elias-alvarez/null-ls.nvim',
 | 
			
		||||
 | 
			
		||||
    dependencies = { 'nvim-lua/plenary.nvim' },
 | 
			
		||||
 | 
			
		||||
    config = function ()
 | 
			
		||||
      local null_ls = require("null-ls")
 | 
			
		||||
 | 
			
		||||
      null_ls.setup({
 | 
			
		||||
        sources = {
 | 
			
		||||
          -- general
 | 
			
		||||
          null_ls.builtins.code_actions.gitsigns,
 | 
			
		||||
          -- python
 | 
			
		||||
          -- null_ls.builtins.diagnostics.pylint,
 | 
			
		||||
          null_ls.builtins.formatting.black,
 | 
			
		||||
          null_ls.builtins.formatting.isort,
 | 
			
		||||
          -- typescript
 | 
			
		||||
          null_ls.builtins.formatting.prettier,
 | 
			
		||||
          -- rust
 | 
			
		||||
          -- null_ls.builtins.formatting.rustfmt,
 | 
			
		||||
        },
 | 
			
		||||
      })
 | 
			
		||||
    end
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										76
									
								
								lua/plugins/telescope.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								lua/plugins/telescope.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,76 @@
 | 
			
		||||
return {
 | 
			
		||||
 | 
			
		||||
  { -- Fuzzy Finder (files, lsp, etc)
 | 
			
		||||
    'nvim-telescope/telescope.nvim',
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    version = '*',
 | 
			
		||||
    dependencies = {
 | 
			
		||||
      'nvim-lua/plenary.nvim',
 | 
			
		||||
 | 
			
		||||
      {
 | 
			
		||||
        'nvim-telescope/telescope-fzf-native.nvim',
 | 
			
		||||
        -- NOTE: If you are having trouble with this installation,
 | 
			
		||||
        --       refer to the README for telescope-fzf-native for more instructions.
 | 
			
		||||
        build = 'make',
 | 
			
		||||
        cond = function()
 | 
			
		||||
          return vim.fn.executable 'make' == 1
 | 
			
		||||
        end,
 | 
			
		||||
      },
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    config = function()
 | 
			
		||||
      -- [[ Configure Telescope ]]
 | 
			
		||||
      -- See `:help telescope` and `:help telescope.setup()`
 | 
			
		||||
      require('telescope').setup {
 | 
			
		||||
        defaults = {
 | 
			
		||||
          mappings = {
 | 
			
		||||
            i = {
 | 
			
		||||
              ['<C-u>'] = false,
 | 
			
		||||
              ['<C-d>'] = false,
 | 
			
		||||
            },
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        pickers = {
 | 
			
		||||
          find_files = {
 | 
			
		||||
            find_command = { "rg", "-S", "--no-ignore-vcs", "--hidden", "--files", "-g", "!.git", },
 | 
			
		||||
          }
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      -- Enable telescope fzf native, if installed
 | 
			
		||||
      pcall(require('telescope').load_extension, 'fzf')
 | 
			
		||||
 | 
			
		||||
      -- See `:help telescope.builtin`
 | 
			
		||||
      vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' })
 | 
			
		||||
      vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' })
 | 
			
		||||
      vim.keymap.set('n', '<leader>/', function()
 | 
			
		||||
        -- You can pass additional configuration to telescope to change theme, layout, etc.
 | 
			
		||||
        require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
 | 
			
		||||
          winblend = 10,
 | 
			
		||||
          previewer = false,
 | 
			
		||||
        })
 | 
			
		||||
      end, { desc = '[/] Fuzzily search in current buffer' })
 | 
			
		||||
 | 
			
		||||
      vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' })
 | 
			
		||||
      vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' })
 | 
			
		||||
      vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' })
 | 
			
		||||
      vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' })
 | 
			
		||||
      vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' })
 | 
			
		||||
      vim.keymap.set('n', '<leader>ss', require('telescope.builtin').spell_suggest, { desc = '[S]pell [S]suggest' })
 | 
			
		||||
 | 
			
		||||
      vim.keymap.set('n', '<leader>sc', function()
 | 
			
		||||
        require('telescope.builtin').colorscheme({ enable_preview = true })
 | 
			
		||||
      end, { desc = '[S]earch [C]olorscheme' })
 | 
			
		||||
 | 
			
		||||
      -- extensions
 | 
			
		||||
      -- vim.keymap.set('n', '<leader>fb', require('telescope').extensions.file_browser.file_browser, { desc = '[F]ile [B]rowser' })
 | 
			
		||||
      vim.api.nvim_set_keymap('n', '<leader>tc', ':TodoTelescope<CR>', { desc = '[T]odo [C]omments', noremap = true })
 | 
			
		||||
    end
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
  -- Fuzzy Finder Algorithm which requires local dependencies to be built.
 | 
			
		||||
  -- Only load if `make` is available. Make sure you have the system
 | 
			
		||||
  -- requirements installed.
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										85
									
								
								lua/plugins/treesitter.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								lua/plugins/treesitter.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,85 @@
 | 
			
		||||
return {
 | 
			
		||||
 | 
			
		||||
 -- Highlight, edit, and navigate code
 | 
			
		||||
  'nvim-treesitter/nvim-treesitter',
 | 
			
		||||
  dependencies = {
 | 
			
		||||
    'nvim-treesitter/nvim-treesitter-textobjects',
 | 
			
		||||
    'nvim-treesitter/nvim-treesitter-context',
 | 
			
		||||
    'nvim-treesitter/nvim-treesitter-refactor',
 | 
			
		||||
  },
 | 
			
		||||
  config = function()
 | 
			
		||||
    pcall(require('nvim-treesitter.install').update { with_sync = true })
 | 
			
		||||
 | 
			
		||||
    -- [[ Configure Treesitter ]]
 | 
			
		||||
    -- See `:help nvim-treesitter`
 | 
			
		||||
    require('nvim-treesitter.configs').setup {
 | 
			
		||||
      -- Add languages to be installed here that you want installed for treesitter
 | 
			
		||||
      ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'help', 'vim', 'markdown' },
 | 
			
		||||
 | 
			
		||||
      -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
 | 
			
		||||
      auto_install = true,
 | 
			
		||||
 | 
			
		||||
      highlight = { enable = true },
 | 
			
		||||
      indent = { enable = true, disable = { 'python' } },
 | 
			
		||||
      incremental_selection = {
 | 
			
		||||
        enable = true,
 | 
			
		||||
        keymaps = {
 | 
			
		||||
          init_selection = '<s-space>',
 | 
			
		||||
          node_incremental = '<s-space>',
 | 
			
		||||
          scope_incremental = '<s-s>',
 | 
			
		||||
          node_decremental = '<M-space>',
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
      -- refactor
 | 
			
		||||
      refactor = {
 | 
			
		||||
        highlight_definitions = { enable = true, clear_on_cursor_move = true },
 | 
			
		||||
      },
 | 
			
		||||
      -- textobjects
 | 
			
		||||
      textobjects = {
 | 
			
		||||
        select = {
 | 
			
		||||
          enable = true,
 | 
			
		||||
          lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
 | 
			
		||||
          keymaps = {
 | 
			
		||||
            -- You can use the capture groups defined in textobjects.scm
 | 
			
		||||
            ['aa'] = '@parameter.outer',
 | 
			
		||||
            ['ia'] = '@parameter.inner',
 | 
			
		||||
            ['af'] = '@function.outer',
 | 
			
		||||
            ['if'] = '@function.inner',
 | 
			
		||||
            ['ac'] = '@class.outer',
 | 
			
		||||
            ['ic'] = '@class.inner',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        move = {
 | 
			
		||||
          enable = true,
 | 
			
		||||
          set_jumps = true, -- whether to set jumps in the jumplist
 | 
			
		||||
          goto_next_start = {
 | 
			
		||||
            [']m'] = '@function.outer',
 | 
			
		||||
            [']]'] = '@class.outer',
 | 
			
		||||
          },
 | 
			
		||||
          goto_next_end = {
 | 
			
		||||
            [']M'] = '@function.outer',
 | 
			
		||||
            [']['] = '@class.outer',
 | 
			
		||||
          },
 | 
			
		||||
          goto_previous_start = {
 | 
			
		||||
            ['[m'] = '@function.outer',
 | 
			
		||||
            ['[['] = '@class.outer',
 | 
			
		||||
          },
 | 
			
		||||
          goto_previous_end = {
 | 
			
		||||
            ['[M'] = '@function.outer',
 | 
			
		||||
            ['[]'] = '@class.outer',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
        swap = {
 | 
			
		||||
          enable = true,
 | 
			
		||||
          swap_next = {
 | 
			
		||||
            ['<leader>a'] = '@parameter.inner',
 | 
			
		||||
          },
 | 
			
		||||
          swap_previous = {
 | 
			
		||||
            ['<leader>A'] = '@parameter.inner',
 | 
			
		||||
          },
 | 
			
		||||
        },
 | 
			
		||||
      },
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  end,
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user