360 lines
12 KiB
Lua
360 lines
12 KiB
Lua
-- Only required if you have packer configured as `opt`
|
|
local ensure_packer = function()
|
|
local fn = vim.fn
|
|
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
|
if fn.empty(fn.glob(install_path)) > 0 then
|
|
fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path })
|
|
vim.cmd [[packadd packer.nvim]]
|
|
return true
|
|
end return false
|
|
end
|
|
|
|
local packer_bootstrap = ensure_packer()
|
|
|
|
-- Use a protected call so we don't error out on first use
|
|
local status_ok, packer = pcall(require, 'packer')
|
|
if not status_ok then
|
|
return
|
|
end
|
|
|
|
-- Have packer use a popup window
|
|
packer.init({
|
|
display = {
|
|
open_fn = function()
|
|
return require('packer.util').float({ border = 'rounded' })
|
|
end,
|
|
},
|
|
})
|
|
|
|
|
|
packer.startup(function(use)
|
|
-- Packer can manage itself
|
|
use 'wbthomason/packer.nvim'
|
|
use 'nvim-lua/plenary.nvim'
|
|
use {
|
|
'nvim-telescope/telescope-fzf-native.nvim',
|
|
run = 'make',
|
|
cond = vim.fn.executable 'make' == 1
|
|
}
|
|
use {
|
|
'marko-cerovac/material.nvim',
|
|
config = function()
|
|
-- vim.g.material_style = 'lighter'
|
|
vim.g.material_style = 'palenight'
|
|
vim.cmd [[colorscheme material]]
|
|
end
|
|
}
|
|
use {
|
|
'nvim-treesitter/nvim-treesitter',
|
|
run = function()
|
|
local ts_update = require('nvim-treesitter.install').update({ with_sync = true })
|
|
ts_update()
|
|
end
|
|
}
|
|
use {
|
|
'nvim-treesitter/nvim-treesitter-textobjects',
|
|
after = 'nvim-treesitter',
|
|
}
|
|
use {
|
|
'neovim/nvim-lspconfig',
|
|
config = function()
|
|
local rt = require('rust-tools')
|
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
|
local border = {
|
|
{"🭽", "FloatBorder"},
|
|
{"▔", "FloatBorder"},
|
|
{"🭾", "FloatBorder"},
|
|
{"▕", "FloatBorder"},
|
|
{"🭿", "FloatBorder"},
|
|
{"▁", "FloatBorder"},
|
|
{"🭼", "FloatBorder"},
|
|
{"▏", "FloatBorder"},
|
|
}
|
|
|
|
local handlers = {
|
|
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border}),
|
|
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border }),
|
|
}
|
|
|
|
local on_attach = function(_, bufnr)
|
|
show_diagnostics = true
|
|
local toggle_diagnostics = function()
|
|
if show_diagnostics then
|
|
vim.diagnostic.enable()
|
|
else
|
|
vim.diagnostic.disable()
|
|
end
|
|
show_diagnostics = not show_diagnostics
|
|
end
|
|
show_hints = false
|
|
local toggle_hints = function()
|
|
if show_hints then
|
|
rt.inlay_hints.enable()
|
|
else
|
|
rt.inlay_hints.disable()
|
|
end
|
|
show_hints = not show_hints
|
|
end
|
|
|
|
vim.diagnostic.config {
|
|
float = { border = 'rounded' },
|
|
}
|
|
vim.keymap.set('n', '<leader>te', toggle_diagnostics)
|
|
vim.keymap.set('n', '<leader>ti', toggle_hints)
|
|
vim.diagnostic.config({
|
|
virtual_text = true,
|
|
signs = true,
|
|
underline = true,
|
|
update_in_insert = false,
|
|
severity_sort = false,
|
|
})
|
|
|
|
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
|
vim.keymap.set('n', '<C-space>', rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
vim.keymap.set('n', '<Leader>a', rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
|
vim.keymap.set('n', '<space>lwa', vim.lsp.buf.add_workspace_folder, bufopts)
|
|
vim.keymap.set('n', '<space>lwr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
|
local ws_folders = function()
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
end
|
|
vim.keymap.set('n', '<space>lwl', ws_folders, bufopts)
|
|
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, bufopts)
|
|
vim.keymap.set('n', '<space>lr', vim.lsp.buf.rename, bufopts)
|
|
vim.keymap.set('n', '<space>la', vim.lsp.buf.code_action, bufopts)
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
vim.keymap.set('n', '<space>lf', function() vim.lsp.buf.format { async = true } end, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>ee', vim.diagnostic.open_float, opts)
|
|
vim.keymap.set('n', '<M-S-e>', vim.diagnostic.goto_prev, opts)
|
|
vim.keymap.set('n', '<M-e>', vim.diagnostic.goto_next, opts)
|
|
|
|
rt.inlay_hints.disable()
|
|
vim.diagnostic.disable()
|
|
end
|
|
rt.setup({
|
|
server = {
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
handlers = handlers
|
|
},
|
|
})
|
|
end
|
|
}
|
|
use 'hrsh7th/cmp-nvim-lsp'
|
|
use 'hrsh7th/cmp-buffer'
|
|
use 'hrsh7th/cmp-path'
|
|
use 'hrsh7th/cmp-cmdline'
|
|
use 'hrsh7th/cmp-nvim-lua'
|
|
use 'hrsh7th/cmp-nvim-lsp-signature-help'
|
|
use 'saadparwaiz1/cmp_luasnip'
|
|
use 'L3MON4D3/LuaSnip'
|
|
use {
|
|
'hrsh7th/nvim-cmp',
|
|
config = function()
|
|
local cmp = require('cmp')
|
|
cmp.setup({
|
|
view = {
|
|
entries = {name = 'wildmenu', separator = '|' }
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
require'luasnip'.lsp_expand(args.body)
|
|
end
|
|
},
|
|
window = {
|
|
completion = cmp.config.window.bordered(),
|
|
documentation = cmp.config.window.bordered(),
|
|
},
|
|
mapping = cmp.mapping.preset.insert({
|
|
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
|
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
|
['<C-Space>'] = cmp.mapping.complete(),
|
|
['<C-e>'] = cmp.mapping.abort(),
|
|
['<C-f>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
}),
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp_signature_help' },
|
|
{ name = 'nvim_lua' },
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'buffer' },
|
|
{ name = 'path' },
|
|
}),
|
|
experimental = {
|
|
ghost_text = true,
|
|
},
|
|
})
|
|
vim.keymap.set('i', '<C-Space>', cmp.complete)
|
|
end
|
|
}
|
|
use {
|
|
'simrat39/rust-tools.nvim'
|
|
}
|
|
use {
|
|
'j-hui/fidget.nvim',
|
|
after = 'rust-tools.nvim',
|
|
config = function()
|
|
require('fidget').setup({})
|
|
end
|
|
}
|
|
use 'mfussenegger/nvim-dap'
|
|
use {
|
|
'rcarriga/nvim-dap-ui',
|
|
requires = {'mfussenegger/nvim-dap'},
|
|
config = function()
|
|
require('dapui').setup()
|
|
end,
|
|
}
|
|
use 'mbbill/undotree'
|
|
use {
|
|
'nvim-telescope/telescope.nvim', tag = '0.1.0',
|
|
requires = { {'nvim-lua/plenary.nvim'} }
|
|
}
|
|
use {
|
|
'numToStr/Comment.nvim',
|
|
config = function()
|
|
require('Comment').setup()
|
|
end
|
|
}
|
|
use {
|
|
'kylechui/nvim-surround',
|
|
tag = '*', -- Use for stability; omit to use `main` branch for the latest features
|
|
config = function()
|
|
require('nvim-surround').setup({})
|
|
end
|
|
}
|
|
use {
|
|
'm4xshen/autoclose.nvim',
|
|
config = function()
|
|
require('autoclose').setup({})
|
|
end
|
|
}
|
|
use {
|
|
'ggandor/leap.nvim',
|
|
config = function()
|
|
require('leap').add_default_mappings()
|
|
end
|
|
}
|
|
use {
|
|
"folke/zen-mode.nvim",
|
|
config = function()
|
|
require("zen-mode").setup {
|
|
vim.keymap.set('n', '<leader>tz', vim.cmd.ZenMode)
|
|
}
|
|
end
|
|
}
|
|
-- use { 'TimUntersberger/neogit', requires = 'nvim-lua/plenary.nvim' }
|
|
end)
|
|
|
|
if packer_bootstrap then
|
|
require('packer').sync()
|
|
end
|
|
|
|
local autocmd = vim.api.nvim_create_autocmd
|
|
local augroup = vim.api.nvim_create_augroup
|
|
|
|
|
|
autocmd(('BufWritePost'), {
|
|
group = augroup('packer_user_config', { clear = true }),
|
|
pattern = 'plugins.lua',
|
|
once = true,
|
|
callback = function()
|
|
vim.cmd('source ~/.config/nvim/lua/plugins.lua')
|
|
packer.compile()
|
|
end
|
|
})
|
|
|
|
require('nvim-treesitter.configs').setup {
|
|
-- Add languages to be installed here that you want installed for treesitter
|
|
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'bash', 'rust', 'go', 'help', 'haskell', 'ocaml' },
|
|
highlight = {
|
|
enable = true,
|
|
additional_vim_regex_highlighting = false
|
|
},
|
|
indent = { enable = true },
|
|
incremental_selection = {
|
|
enable = true,
|
|
keymaps = {
|
|
init_selection = '<c-space>',
|
|
node_incremental = '<c-space>',
|
|
scope_incremental = '<c-s>',
|
|
node_decremental = '<c-backspace>',
|
|
},
|
|
},
|
|
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 = {
|
|
[')'] = '@function.outer',
|
|
[']]'] = '@class.outer',
|
|
},
|
|
goto_next_end = {
|
|
[']M'] = '@function.outer',
|
|
[']['] = '@class.outer',
|
|
},
|
|
goto_previous_start = {
|
|
['('] = '@function.outer',
|
|
['[['] = '@class.outer',
|
|
},
|
|
goto_previous_end = {
|
|
['[M'] = '@function.outer',
|
|
['[]'] = '@class.outer',
|
|
},
|
|
},
|
|
-- TODO: Fix this
|
|
swap = {
|
|
enable = true,
|
|
swap_next = {
|
|
['<leader>a'] = '@parameter.inner',
|
|
},
|
|
swap_previous = {
|
|
['<leader>A'] = '@parameter.inner',
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
local dap = require('dap')
|
|
dap.adapters.lldb = {
|
|
type = 'executable',
|
|
command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path
|
|
name = 'lldb'
|
|
}
|
|
|
|
dap.configurations.rust = {
|
|
{
|
|
name = 'Launch',
|
|
type = 'lldb',
|
|
request = 'launch',
|
|
program = function()
|
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
end,
|
|
cwd = '${workspaceFolder}',
|
|
stopOnEntry = false,
|
|
args = {},
|
|
},
|
|
}
|
|
|
|
-- If you want to use this for Rust and C, add something like this:
|
|
|
|
dap.configurations.c = dap.configurations.rust
|
|
dap.configurations.cpp = dap.configurations.rust
|