From e6896269f8b7da02ef9e7e386bee6890e2d1b997 Mon Sep 17 00:00:00 2001 From: Kayden Tebau Date: Mon, 18 Sep 2023 16:45:48 -0700 Subject: [PATCH] Add telescope and trouble bindings --- nvim/init.vim | 45 ++++++----- nvim/lua/lsp.lua | 35 +++++---- nvim/lua/plugins.lua | 183 +++++++++++++++++++++++-------------------- 3 files changed, 143 insertions(+), 120 deletions(-) diff --git a/nvim/init.vim b/nvim/init.vim index 8870c03..ca4fe33 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,7 +1,10 @@ +let g:mapleader = "," + lua require('plugins') lua require('lsp') -nmap :wincmd k + +map :wincmd k nmap :wincmd j nmap :wincmd h nmap :wincmd l @@ -25,25 +28,8 @@ autocmd BufLeave term://* stopinsert nnoremap Terminal " Move to previous/next -nnoremap BufferPrevious -nnoremap BufferNext -" Re-order to previous/next -nnoremap BufferMovePrevious -nnoremap > BufferMoveNext -nnoremap BufferGoto 1 -nnoremap BufferGoto 2 -nnoremap BufferGoto 3 -nnoremap BufferGoto 4 -nnoremap BufferGoto 5 -nnoremap BufferGoto 6 -nnoremap BufferGoto 7 -nnoremap BufferGoto 8 -nnoremap BufferGoto 9 -nnoremap BufferLast -" Pin/unpin buffer -nnoremap BufferPin -" Close buffer -nnoremap BufferClose +nnoremap bprevious +nnoremap bnext " Wipeout buffer " :BufferWipeout " Close commands @@ -104,3 +90,22 @@ let g:neovide_floating_blur_amount_y = 2.0 let g:neovide_floating_opacity = 60 set guifont=SFMono\ Nerd\ Font + +sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=DiagnosticSignError +sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=DiagnosticSignWarn +sign define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl=DiagnosticSignInfo +sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl=DiagnosticSignHint + +" Trouble +nnoremap xx TroubleToggle +nnoremap xw TroubleToggle workspace_diagnostics +nnoremap xd TroubleToggle document_diagnostics +nnoremap xq TroubleToggle quickfix +nnoremap xl TroubleToggle loclist +nnoremap gR TroubleToggle lsp_references + +" Telescope +nnoremap ff Telescope find_files +nnoremap fg Telescope live_grep +nnoremap fb Telescope buffers +nnoremap fh Telescope help_tags diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua index 9dabe60..3a0904b 100644 --- a/nvim/lua/lsp.lua +++ b/nvim/lua/lsp.lua @@ -1,10 +1,10 @@ -- Mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions local opts = { noremap = true, silent = true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) local navic = require("nvim-navic") @@ -22,22 +22,31 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set('n', 'wl', function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) + vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', function () + vim.keymap.set('n', 'f', function() vim.lsp.buf.format({ async = true }) end, bufopts) if client.server_capabilities.documentSymbolProvider then navic.attach(client, bufnr) end + + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = { + prefix = "", + spacing = 4, + }, + signs = true, + underline = true, + }) end local lsp_flags = { @@ -101,6 +110,9 @@ cmp.setup.cmdline(':', { }) }) +require "neodev".setup { +} + mason.setup() mason_lspconfig.setup() @@ -121,8 +133,3 @@ mason_lspconfig.setup_handlers { lspconfig[server_name].setup {} end, } - - ---for _, server in ipairs(lsp_installer.get_installed_servers()) do --- lspconfig[server.name].setup {} ---end diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 2e245ab..46f9faf 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -7,10 +7,9 @@ require('packer').startup(function(use) use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' } use { "ellisonleao/gruvbox.nvim" } - use 'neovim/nvim-lspconfig' -- Configurations for Nvim LSP - use{ + use { "williamboman/mason.nvim", "williamboman/mason-lspconfig.nvim", } @@ -60,58 +59,64 @@ require('packer').startup(function(use) --use 'vim-airline/vim-airline-themes' use 'lervag/vimtex' + use 'folke/neodev.nvim' + use 'kosayoda/nvim-lightbulb' + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.x', + requires = { { 'nvim-lua/plenary.nvim' } } + } end) require("gruvbox").setup({ - undercurl = true, - underline = true, - bold = true, - italic = { - strings = true, - comments = true, - }, - strikethrough = true, - invert_selection = false, - invert_signs = false, - invert_tabline = false, - invert_intend_guides = false, - inverse = true, -- invert background for search, diffs, statuslines and errors - contrast = "soft", -- can be "hard", "soft" or empty string - overrides = {}, + undercurl = true, + underline = true, + bold = true, + italic = { + strings = true, + comments = true, + }, + strikethrough = true, + invert_selection = false, + invert_signs = false, + invert_tabline = false, + invert_intend_guides = false, + inverse = true, -- invert background for search, diffs, statuslines and errors + contrast = "soft", -- can be "hard", "soft" or empty string + overrides = {}, }) -require'nvim-treesitter.configs'.setup { - -- A list of parser names, or "all" - ensure_installed = "all", +require 'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" + ensure_installed = "all", - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = true, + -- Automatically install missing parsers when entering buffer + auto_install = true, - -- List of parsers to ignore installing (for "all") - ignore_install = { "phpdoc" }, + -- List of parsers to ignore installing (for "all") + ignore_install = { "phpdoc" }, - ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) - -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! + ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) + -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! - highlight = { - -- `false` will disable the whole extension - enable = true, + highlight = { + -- `false` will disable the whole extension + enable = true, - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- list of language that will be disabled - disable = { }, + -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to + -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is + -- the name of the parser) + -- list of language that will be disabled + disable = {}, - -- Setting this to true will run `:h syntax` and tree-sitter at the same time. - -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages - additional_vim_regex_highlighting = false, - }, + -- Setting this to true will run `:h syntax` and tree-sitter at the same time. + -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). + -- Using this option may slow down your editor, and you may see some duplicate highlights. + -- Instead of true it can also be a list of languages + additional_vim_regex_highlighting = false, + }, } @@ -138,10 +143,12 @@ require('lualine').setup { options = { icons_enabled = true, theme = 'gruvbox', - component_separators = { left = '', right = ''}, - section_separators = { left = '', right = ''}, + component_separators = { left = '', right = '' }, + section_separators = { left = '', right = '' }, disabled_filetypes = { - statusline = {}, + statusline = { + "neo-tree", + }, winbar = { "help", "startify", @@ -149,6 +156,7 @@ require('lualine').setup { "packer", "neogitstatus", "NvimTree", + "neo-tree", "Trouble", "alpha", "lir", @@ -167,18 +175,18 @@ require('lualine').setup { } }, sections = { - lualine_a = {'mode'}, - lualine_b = {'diff', 'diagnostics'}, - lualine_c = {'filename'}, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} + lualine_a = { 'mode' }, + lualine_b = { '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_c = { 'filename' }, + lualine_x = { 'location' }, lualine_y = {}, lualine_z = {}, }, @@ -192,13 +200,13 @@ require('lualine').setup { lualine_b = { "branch" }, - lualine_c = {'hostname'}, + lualine_c = { 'hostname' }, lualine_x = {}, lualine_y = {}, - lualine_z = {'tabs', 'datetime'}, + lualine_z = { 'tabs', 'datetime' }, }, winbar = { - lualine_a = {'searchcount'}, + lualine_a = { 'searchcount' }, lualine_b = {}, lualine_c = { "filename", @@ -221,35 +229,38 @@ require('lualine').setup { }, extensions = {} } -require'nvim-navic'.setup { - icons = { - File = ' ', - Module = ' ', - Namespace = ' ', - Package = ' ', - Class = ' ', - Method = ' ', - Property = ' ', - Field = ' ', - Constructor = ' ', - Enum = ' ', - Interface = ' ', - Function = ' ', - Variable = ' ', - Constant = ' ', - String = ' ', - Number = ' ', - Boolean = ' ', - Array = ' ', - Object = ' ', - Key = ' ', - Null = ' ', - EnumMember = ' ', - Struct = ' ', - Event = ' ', - Operator = ' ', - TypeParameter = ' ', - }, - separator = '  ', +require 'nvim-navic'.setup { + icons = { + File = ' ', + Module = ' ', + Namespace = ' ', + Package = ' ', + Class = ' ', + Method = ' ', + Property = ' ', + Field = ' ', + Constructor = ' ', + Enum = ' ', + Interface = ' ', + Function = ' ', + Variable = ' ', + Constant = ' ', + String = ' ', + Number = ' ', + Boolean = ' ', + Array = ' ', + Object = ' ', + Key = ' ', + Null = ' ', + EnumMember = ' ', + Struct = ' ', + Event = ' ', + Operator = ' ', + TypeParameter = ' ', + }, + separator = '  ', } +require 'nvim-lightbulb'.setup { + autocmd = { enabled = true } +}