@ -188,6 +188,11 @@ require('lazy').setup({
} ,
} ,
} ,
-- File browser
{
" nvim-telescope/telescope-file-browser.nvim " ,
dependencies = { " nvim-telescope/telescope.nvim " , " nvim-lua/plenary.nvim " }
} ,
{
-- Highlight, edit, and navigate code
@ -198,6 +203,18 @@ require('lazy').setup({
build = ' :TSUpdate ' ,
} ,
{
" nvim-tree/nvim-tree.lua " ,
version = " * " ,
dependencies = {
" nvim-tree/nvim-web-devicons " ,
} ,
config = function ( )
require ( " nvim-tree " ) . setup { }
end ,
} ,
' jremmen/vim-ripgrep ' ,
-- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart
-- These are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them.
@ -218,7 +235,7 @@ require('lazy').setup({
-- NOTE: You can change these options as you wish!
-- Set highlight on search
vim.o . hlsearch = fals e
vim.o . hlsearch = tru e
-- Make line numbers default
vim.wo . number = true
@ -288,6 +305,8 @@ require('telescope').setup {
} ,
}
require ( " telescope " ) . load_extension " file_browser "
-- Enable telescope fzf native, if installed
pcall ( require ( ' telescope ' ) . load_extension , ' fzf ' )
@ -381,6 +400,9 @@ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnos
vim.keymap . set ( ' n ' , ' <leader>e ' , vim.diagnostic . open_float , { desc = ' Open floating diagnostic message ' } )
vim.keymap . set ( ' n ' , ' <leader>q ' , vim.diagnostic . setloclist , { desc = ' Open diagnostics list ' } )
-- Nvim Tree browser
vim.keymap . set ( ' n ' , ' <C-e> ' , " <cmd>NvimTreeToggle<CR> " , { desc = " Open file explorer " } )
-- [[ Configure LSP ]]
-- This function gets run when an LSP connects to a particular buffer.
local on_attach = function ( _ , bufnr )
@ -402,6 +424,7 @@ local on_attach = function(_, bufnr)
nmap ( ' <leader>ca ' , vim.lsp . buf.code_action , ' [C]ode [A]ction ' )
nmap ( ' gd ' , vim.lsp . buf.definition , ' [G]oto [D]efinition ' )
nmap ( ' ge ' , vim.diagnostic . open_float , ' [G]oto Error ' )
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 ' )
@ -466,13 +489,21 @@ mason_lspconfig.setup {
mason_lspconfig.setup_handlers {
function ( server_name )
require ( ' lspconfig ' ) [ server_name ] . setup {
capabilities = capabilities ,
on_attach = on_attach ,
settings = servers [ server_name ] ,
filetypes = ( servers [ server_name ] or { } ) . filetypes ,
}
end
if ' clangd ' == server_name then
require ( ' lspconfig ' ) [ server_name ] . setup {
capabilities = capabilities ,
on_attach = on_attach ,
settings = servers [ server_name ] ,
cmd = { ' clangd ' , ' --background-index ' , ' -header-insertion=never ' }
}
else
require ( ' lspconfig ' ) [ server_name ] . setup {
capabilities = capabilities ,
on_attach = on_attach ,
settings = servers [ server_name ] ,
}
end
end ,
}
-- [[ Configure nvim-cmp ]]
@ -488,11 +519,11 @@ cmp.setup {
luasnip.lsp_expand ( args.body )
end ,
} ,
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 . s cro ll_d oc s( 4 ) ,
mapping = {
[ ' <C- d >' ] = cmp.mapping . select_next_item ( ) ,
[ ' <C- s >' ] = cmp.mapping . select_prev_item ( ) ,
--['<C-d>'] = cmp.mapping.scroll_docs(-4) ,
[ ' <C- e >' ] = cmp.mapping . close ( ) ,
[ ' <C-Space> ' ] = cmp.mapping . complete { } ,
[ ' <CR> ' ] = cmp.mapping . confirm {
behavior = cmp.ConfirmBehavior . Replace ,
@ -525,3 +556,12 @@ cmp.setup {
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
--nvim-tree.actions.change_dir.enable = false
vim.keymap . set ( ' i ' , ' <S-Tab> ' , ' <Tab> ' , { desc = ' Make Tabs ' } )
vim.keymap . set ( ' n ' , ' Q ' , ' "_d ' , { desc = ' Make Tabs ' } )
vim.api . nvim_create_autocmd ( { " BufWritePre " } , {
pattern = { " * " } ,
command = [[%s/\s\+$//e]] ,
} )