Set neovim as EDITOR in .bashrc and update neovim config

arch
kalle 2022-10-11 16:36:39 +02:00
parent bc0a2f2da0
commit 1f502fb6f3
6 changed files with 291 additions and 29 deletions

View File

@ -5,6 +5,9 @@
# Add ~/bin and ~/bin/scripts to my path
export PATH=$PATH:$HOME/bin/:$HOME/bin/scripts/
# Set editor to neovim.
export EDITOR=nvim
# Prompt stuff
#
# LINEAGE:

View File

@ -19,13 +19,26 @@ vim.opt.modeline = true
vim.opt.undofile = true
vim.g.mapleader = ' '
vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'}
vim.opt.shortmess = vim.opt.shortmess + { c = true}
vim.api.nvim_set_option('updatetime', 100)
-- Fixed column for diagnostics to appear
-- Show autodiagnostic popup on cursor hover_range
-- Goto previous / next diagnostic warning / error
-- Show inlay_hints more frequently
vim.cmd([[
set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]])
-- Load utilities
require('kalle.utils')
-- Load plugins
require('kalle.plugins')
vim.cmd('colorscheme nightfox')
vim.cmd('colorscheme carbonfox')
-- Load config
require('kalle.config')

View File

@ -38,5 +38,32 @@ Keybind.g({
-- [ space + o + f] Open file
{ 'n', '<Leader>of', '<Cmd>Telescope git_files<CR>', { noremap = true, desc = 'Open file' } },
-- [ space + c] Code
{ 'n', '<Leader>c', '', {noremap = true, desc = '+Code' } },
-- [ space + c + a] Code actions
{ 'n', '<Leader>ca', '<Cmd>lua vim.lsp.buf.code_action()<CR>', {noremap = true, desc = 'Code actions' } },
-- [ space + c]
{ 'n', '<Leader>cr', '<Cmd>Telescope lsp_references<CR>', {noremap = true, desc = 'References' } },
-- [ space + c]
{ 'n', '<Leader>cd', '<Cmd>Telescope lsp_definitions<CR>', {noremap = true, desc = 'Definitions' } },
-- [space + F9] Launch vimspector
{ 'n', '<Leader><F9>', '<Cmd>call vimspector#Launch()<cr>', {noremap = true, desc = "Launch vimspector"}},
-- [F5] Step over
{ 'n', '<F5>', '<Cmd>call vimspector#StepOver()<cr>', {noremap = true, desc = "Step over"}},
-- [space + F8] Reset vimspector
{ 'n', '<Leader><F8>', '<Cmd>call vimspector#Reset()<cr>', {noremap = true, desc = "Reset vimspector"}},
-- [F12] Step out
{ 'n', '<F12>', '<Cmd>call vimspector#StepOut()<cr>', {noremap = true, desc = "Step out"}},
-- [F11] Continue
{ 'n', '<F11>', '<Cmd>call vimspector#Continue()<cr>', {noremap = true, desc = "Continue"} },
-- [F10] Step into
{ 'n', '<F10>', '<Cmd>call vimspector#StepInto()<cr>', {noremap = true, desc = "Step into"}},
-- [ D + b] Toggle breakpoint
{'n', "Db", ":call vimspector#ToggleBreakpoint()<cr>", {noremap = true, desc = "Toggle breakpoint"}},
-- [ D + w] Add watch
{'n', "Dw", ":call vimspector#AddWatch()<cr>", {noremap = true, desc = "Add watch"}},
-- [ D + e] Evaluate
{'n', "De", ":call vimspector#Evaluate()<cr>", {noremap = true, desc = "Evaluate"}},
})

View File

@ -84,21 +84,51 @@ local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
-- Add tab support
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<Tab>'] = cmp.mapping.select_next_item(),
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<C-e>'] = cmp.mapping.close(),
['<CR>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
})
}),
sources = cmp.config.sources({
{ name = 'path' }, -- file paths
{ name = 'nvim_lsp', keyword_length = 3 }, -- from language server
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
{ name = 'calc'}, -- source for math calculation
{ name = 'nvim_lsp' },
}, {
{ name = 'buffer' },
})
}),
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = {'menu', 'abbr', 'kind'},
format = function(entry, item)
local menu_icon ={
nvim_lsp = 'λ',
vsnip = '',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
})
cmp.setup.filetype('gitcommit', {
@ -164,6 +194,8 @@ require("mason-lspconfig").setup_handlers({
end,
})
require('mason-nvim-dap').setup()
require('gitsigns').setup {
current_line_blame = true,
}
@ -171,6 +203,7 @@ require('gitsigns').setup {
require('marks').setup {}
require('nvim-treesitter.configs').setup {
ensure_installed = { "lua", "rust", "toml" },
auto_install = true,
highlight = {
enable = true,
@ -179,4 +212,85 @@ require('nvim-treesitter.configs').setup {
indent = {
enable = true
},
rainbow = {
enable = true,
extended_mode = true,
max_file_lines = nil,
}
}
-- Treesitter folding
vim.wo.foldmethod = 'expr'
vim.wo.foldexpr = 'nvim_treesitter#foldexpr()'
vim.o.foldenable = false
require('Comment').setup()
require('illuminate').configure()
local rt_config = {
server = {
settings = {
on_attach = function(_, bufnr)
-- Hover actions
vim.keymap.set("n", "<C-space>", rt_config.hover_actions.hover_actions, { buffer = bufnr })
-- Code action groups
vim.keymap.set("n", "<Leader>a", rt_config.code_action_group.code_action_group, { buffer = bufnr })
require 'illuminate'.on_attach(client)
end,
["rust-analyzer"] = {
checkOnSave = {
command = "clippy"
},
},
}
},
}
require('rust-tools').setup()
-- LSP Diagnostics Options Setup
local sign = function(opts)
vim.fn.sign_define(opts.name, {
texthl = opts.name,
text = opts.text,
numhl = ''
})
end
sign({name = 'DiagnosticSignError', text = ''})
sign({name = 'DiagnosticSignWarn', text = ''})
sign({name = 'DiagnosticSignHint', text = ''})
sign({name = 'DiagnosticSignInfo', text = ''})
vim.diagnostic.config({
virtual_text = false,
signs = true,
update_in_insert = true,
underline = true,
severity_sort = false,
float = {
border = 'rounded',
source = 'always',
header = '',
prefix = '',
},
})
vim.cmd([[
set signcolumn=yes
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
]])
-- Vimspector options
vim.cmd([[
let g:vimspector_sidebar_width = 85
let g:vimspector_bottombar_height = 15
let g:vimspector_terminal_maxwidth = 70
]])
require('nvim-lightbulb').setup({autocmd = {enabled = true}})
require("telescope").load_extension("ui-select")
require("todo-comments").setup {}

View File

@ -17,11 +17,20 @@ return require('packer').startup({function(use)
use('EdenEast/nightfox.nvim')
use('folke/which-key.nvim')
use('numToStr/Comment.nvim')
use('RRethy/vim-illuminate')
use {
'nvim-treesitter/nvim-treesitter',
run = function() require('nvim-treesitter.install').update({ with_sync = true }) end,
}
use('antoinemadec/FixCursorHold.nvim')
use {
'kosayoda/nvim-lightbulb',
requires = 'antoinemadec/FixCursorHold.nvim',
}
use {
'kyazdani42/nvim-tree.lua',
requires = {
@ -34,18 +43,27 @@ return require('packer').startup({function(use)
"williamboman/mason-lspconfig.nvim",
}
use('simrat39/rust-tools.nvim')
use('chentoast/marks.nvim')
use('neovim/nvim-lspconfig')
use('L3MON4D3/LuaSnip')
use('mfussenegger/nvim-dap')
use('rcarriga/nvim-dap-ui')
use('theHamsta/nvim-dap-virtual-text')
use('nvim-telescope/telescope-dap.nvim')
use('jayp0521/mason-nvim-dap.nvim')
use {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lsp-signature-help',
'hrsh7th/cmp-vsnip',
'hrsh7th/nvim-cmp',
'hrsh7th/vim-vsnip',
}
use 'famiu/bufdelete.nvim'
@ -69,6 +87,11 @@ return require('packer').startup({function(use)
},
}
use('nvim-telescope/telescope-ui-select.nvim')
use('folke/todo-comments.nvim')
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then

View File

@ -9,23 +9,26 @@ vim.api.nvim_command('packadd packer.nvim')
local no_errors, error_msg = pcall(function()
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
_G._packer = _G._packer or {}
_G._packer.inside_compile = true
local time
local profile_info
local should_profile = false
if should_profile then
local hrtime = vim.loop.hrtime
profile_info = {}
time = function(chunk, start)
if start then
profile_info[chunk] = hrtime()
else
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
end
else
time = function(chunk, start) end
end
else
time = function(chunk, start) end
end
local function save_profiles(threshold)
local sorted_times = {}
for chunk_name, time_taken in pairs(profile_info) do
@ -38,8 +41,10 @@ local function save_profiles(threshold)
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
end
end
if threshold then
table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
end
_G._packer = _G._packer or {}
_G._packer.profile_output = results
end
@ -69,10 +74,15 @@ end
time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
LuaSnip = {
["Comment.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/LuaSnip",
url = "https://github.com/L3MON4D3/LuaSnip"
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/Comment.nvim",
url = "https://github.com/numToStr/Comment.nvim"
},
["FixCursorHold.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/FixCursorHold.nvim",
url = "https://github.com/antoinemadec/FixCursorHold.nvim"
},
["bufdelete.nvim"] = {
loaded = true,
@ -99,11 +109,21 @@ _G.packer_plugins = {
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp",
url = "https://github.com/hrsh7th/cmp-nvim-lsp"
},
["cmp-nvim-lsp-signature-help"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp-signature-help",
url = "https://github.com/hrsh7th/cmp-nvim-lsp-signature-help"
},
["cmp-path"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/cmp-path",
url = "https://github.com/hrsh7th/cmp-path"
},
["cmp-vsnip"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/cmp-vsnip",
url = "https://github.com/hrsh7th/cmp-vsnip"
},
["gitsigns.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/gitsigns.nvim",
@ -124,6 +144,11 @@ _G.packer_plugins = {
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/mason-lspconfig.nvim",
url = "https://github.com/williamboman/mason-lspconfig.nvim"
},
["mason-nvim-dap.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/mason-nvim-dap.nvim",
url = "https://github.com/jayp0521/mason-nvim-dap.nvim"
},
["mason.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/mason.nvim",
@ -144,6 +169,26 @@ _G.packer_plugins = {
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/nvim-cmp",
url = "https://github.com/hrsh7th/nvim-cmp"
},
["nvim-dap"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/nvim-dap",
url = "https://github.com/mfussenegger/nvim-dap"
},
["nvim-dap-ui"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/nvim-dap-ui",
url = "https://github.com/rcarriga/nvim-dap-ui"
},
["nvim-dap-virtual-text"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/nvim-dap-virtual-text",
url = "https://github.com/theHamsta/nvim-dap-virtual-text"
},
["nvim-lightbulb"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/nvim-lightbulb",
url = "https://github.com/kosayoda/nvim-lightbulb"
},
["nvim-lspconfig"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/nvim-lspconfig",
@ -174,11 +219,41 @@ _G.packer_plugins = {
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/plenary.nvim",
url = "https://github.com/nvim-lua/plenary.nvim"
},
["rust-tools.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/rust-tools.nvim",
url = "https://github.com/simrat39/rust-tools.nvim"
},
["telescope-dap.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/telescope-dap.nvim",
url = "https://github.com/nvim-telescope/telescope-dap.nvim"
},
["telescope-ui-select.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/telescope-ui-select.nvim",
url = "https://github.com/nvim-telescope/telescope-ui-select.nvim"
},
["telescope.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/telescope.nvim",
url = "https://github.com/nvim-telescope/telescope.nvim"
},
["todo-comments.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/todo-comments.nvim",
url = "https://github.com/folke/todo-comments.nvim"
},
["vim-illuminate"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/vim-illuminate",
url = "https://github.com/RRethy/vim-illuminate"
},
["vim-vsnip"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/vim-vsnip",
url = "https://github.com/hrsh7th/vim-vsnip"
},
["which-key.nvim"] = {
loaded = true,
path = "/home/kalle/.local/share/nvim/site/pack/packer/start/which-key.nvim",
@ -187,6 +262,13 @@ _G.packer_plugins = {
}
time([[Defining packer_plugins]], false)
_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false
if should_profile then save_profiles() end
end)