Vim Update

Signed-off-by: TiagoRG <tiago.rgarcia@ua.pt>
This commit is contained in:
Tiago Garcia 2024-02-24 21:04:19 +00:00 committed by Tiago Garcia
parent 272b599945
commit a251139a12
Signed by: TiagoRG
GPG Key ID: DFCD48E3F420DB42
8 changed files with 72 additions and 68 deletions

View File

@ -5,19 +5,31 @@ lsp.preset("recommended")
-- Fix Undefined global 'vim'
lsp.nvim_workspace()
local luasnip = require("luasnip")
local cmp = require('cmp')
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<Tab>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ select = true })
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" })
})
-- cmp_mappings['<Tab>'] = nil
-- cmp_mappings['<S-Tab>'] = nil
lsp.setup_nvim_cmp({
mapping = cmp_mappings
})

View File

@ -1,12 +1,5 @@
require("luasnip.loaders.from_snipmate").load({ path = { "$HOME/.config/nvim/snippets/" } })
local ls = require("luasnip")
vim.keymap.set({"i"}, "<C-K>", function() ls.expand() end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-D>", function() ls.jump( 1) end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-C>", function() ls.jump(-1) end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-E>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end, {silent = true})

View File

@ -35,7 +35,9 @@ vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
vim.keymap.set("n", "<leader>r", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("v", "<leader>rs", [[:s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("n", "<leader>ra", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
vim.keymap.set("n", "<leader>rc", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gcI<Left><Left><Left><Left>]])
vim.keymap.set("n", "<leader>m", "<cmd>!make > /dev/null<CR>", { silent = true })
@ -49,5 +51,6 @@ vim.api.nvim_exec([[
augroup SearchHighlight
autocmd!
autocmd CmdlineLeave /,\? :nnoremap <buffer> <Esc> :nohls<CR>
autocmd CmdlineChanged /,\? :nnoremap <buffer> <Esc> :nohls<CR>
augroup END
]], false)

View File

@ -1,35 +1,30 @@
-- vim.opt.guicursor = ""
vim.g.mapleader = " "
vim.g.mouse = "a"
-- vim.opt.clipboard = "unnamedplus"
vim.opt.updatetime = 50
vim.opt.wrap = false
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.scrolloff = 10
vim.opt.signcolumn = "yes"
vim.opt.colorcolumn = "0"
vim.opt.smartindent = true
vim.opt.wrap = false
vim.opt.hls = true
vim.opt.is = true
vim.opt.ic = true
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = true
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 10
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.guitablabel = "\\[%N\\]\\ %t\\ %M"
vim.opt.updatetime = 50
vim.opt.colorcolumn = "0"
vim.g.copilot_node_command = "/usr/bin/nodenv"
vim.g.copilot_assume_mapped = true
vim.g.mapleader = " "
vim.g.mouse = "a"

View File

@ -1,14 +1,12 @@
## Main
# main
snippet main
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
${0}
}
# main(void)
snippet mainn
int main(void)
{
int main(void) {
${0}
}
##
@ -141,15 +139,13 @@ snippet do
## Functions
# function definition
snippet fun
${1:void} ${2:function_name}(${3})
{
${4}
${1:void} ${2:function_name}(${3}) {
${0}
}
# function definition with zero parameters
snippet fun0
${1:void} ${2:function_name}()
{
${3}
${1:void} ${2:function_name}() {
${0}
}
# function definition with Doxygen documentation
snippet dfun0
@ -159,15 +155,13 @@ snippet dfun0
*
* \return ${3:Return parameter description}
*/
${4:void} ${5:function_name}()
{
${6}
${4:void} ${5:function_name}() {
${0}
}
# function definition with one parameter
snippet fun1
${1:void} ${2:function_name}(${3:Type} ${4:Parameter})
{
${5}
${1:void} ${2:function_name}(${3:Type} ${4:Parameter}) {
${0}
}
# function definition with one parameter with Doxygen documentation
snippet dfun1
@ -178,15 +172,13 @@ snippet dfun1
* \param $3 ${4:Parameter description}
* \return ${5:Return parameter description}
*/
${6:void} ${7:function_name}(${8:Type} ${3:Parameter})
{
${9}
${6:void} ${7:function_name}(${8:Type} ${3:Parameter}) {
${0}
}
# function definition with two parameters
snippet fun2
${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter})
{
${7}
${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}) {
${0}
}
# function definition with two parameters with Doxygen documentation
snippet dfun2
@ -198,15 +190,13 @@ snippet dfun2
* \param $5 ${6:Parameter description}
* \return ${7:Return parameter description}
*/
${8:void} ${9:function_name}(${10:Type} ${3:Parameter}, ${11:Type} ${5:Parameter})
{
${12}
${8:void} ${9:function_name}(${10:Type} ${3:Parameter}, ${11:Type} ${5:Parameter}) {
${0}
}
# function definition with three parameters
snippet fun3
${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}, ${7:Type} ${8:Parameter})
{
${9}
${1:void} ${2:function_name}(${3:Type} ${4:Parameter}, ${5:Type} ${6:Parameter}, ${7:Type} ${8:Parameter}) {
${0}
}
# function definition with three parameters with Doxygen documentation
snippet dfun3
@ -219,9 +209,8 @@ snippet dfun3
* \param $7 ${8:Parameter description}
* \return ${9:Return parameter description}
*/
${10:void} ${11:function_name}(${12:Type} ${3:Parameter}, ${13:Type} ${5:Parameter}, ${14:Type} ${7:Parameter})
{
${15}
${10:void} ${11:function_name}(${12:Type} ${3:Parameter}, ${13:Type} ${5:Parameter}, ${14:Type} ${7:Parameter}) {
${0}
}
# function declaration
snippet fund

21
.vimrc
View File

@ -1,17 +1,23 @@
syntax on
colorscheme onedark
set nu
set relativenumber
set signcolumn=yes
set colorcolumn=80
set smartindent
set tabstop=4
set shiftwidth=4
set ls=2
set hlsearch
set incsearch
set hls
set is
set ic
set scrolloff=10
let g:mapleader=" "
syntax on
colorscheme onedark
nnoremap <leader>w :w<CR>
nnoremap <leader>e :E<CR>
@ -33,12 +39,15 @@ vnoremap <leader>d "_d
nnoremap <silent> Q @@
nnoremap <leader>r :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
vnoremap <leader>rs :s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
nnoremap <leader>ra :%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>
nnoremap <leader>rc :%s/\<<C-r><C-w>\>/<C-r><C-w>/gcI<Left><Left><Left><Left>
nnoremap <leader>m :!make<CR>
augroup SearchHighlight
autocmd!
autocmd CmdlineLeave /,\? :nnoremap <buffer> <Esc> :nohls<CR>
autocmd CmdlineChanged /,\? :nnoremap <buffer> <Esc> :nohls<CR>
augroup END

View File

@ -323,3 +323,5 @@ export CPATH=/home/tiagorg/.local/include:/opt/pic32mx/include:$CPATH
# For C++ only: CPLUS_INCLUDE_PATH
# For Obj-C: OBJC_INCLUDE_PATH
export LIBRARY_PATH=/home/tiagorg/.local/lib:$LIBRARY_PATH
export SSH_AUTH_SOCK=$XDG_RUNTIME_DIR/gcr/ssh

View File

@ -1 +1,2 @@
ZDOTDIR=/home/tiagorg/.zsh
. "$HOME/.cargo/env"