From 5cef98c6d2b0b4d9c25cb607330e2a55f936988d Mon Sep 17 00:00:00 2001 From: Jose Ignacio Seco Date: Sun, 4 Feb 2024 11:24:11 +0100 Subject: [PATCH] More changes --- .gitignore | 1 + init.lua | 26 ++++---------- lua/my_mappings.lua | 85 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 lua/my_mappings.lua diff --git a/.gitignore b/.gitignore index d699e1d6..ea93edad 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ tags test.sh .luarc.json nvim +lazy-lock.json diff --git a/init.lua b/init.lua index 6c6ae020..12d9f13a 100644 --- a/init.lua +++ b/init.lua @@ -1,19 +1,4 @@ ---[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== - -Kickstart.nvim is *not* a distribution. - -Kickstart.nvim is a template for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you should start exploring, configuring and tinkering to - explore Neovim! - - If you don't know anything about Lua, I recommend taking some time to read through +--[[ ===================================================================== ==================== READ THIS BEFORE CONTINUING ==================== ===================================================================== Kickstart.nvim is *not* a distribution. Kickstart.nvim is a template for your own configuration. The goal is that you can read every line of code, top-to-bottom, understand what your configuration is doing, and modify it to suit your needs. Once you've done that, you should start exploring, configuring and tinkering to explore Neovim! If you don't know anything about Lua, I recommend taking some time to read through a guide. One possible example: - https://learnxinyminutes.com/docs/lua/ @@ -41,8 +26,8 @@ P.S. You can delete this when you're done too. It's your config now :) -- Set as the leader key -- See `:help mapleader` -- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) -vim.g.mapleader = ' ' -vim.g.maplocalleader = ' ' +vim.g.mapleader = ',' +vim.g.maplocalleader = ',' -- [[ Install `lazy.nvim` plugin manager ]] -- https://github.com/folke/lazy.nvim @@ -279,7 +264,7 @@ require('lazy').setup({ -- NOTE: You can change these options as you wish! -- Set highlight on search -vim.o.hlsearch = false +vim.o.hlsearch = true -- Make line numbers default vim.wo.number = true @@ -667,5 +652,8 @@ cmp.setup { }, } +-- require my mappings. +require('my_mappings') + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/my_mappings.lua b/lua/my_mappings.lua new file mode 100644 index 00000000..c137d372 --- /dev/null +++ b/lua/my_mappings.lua @@ -0,0 +1,85 @@ + +-- My personal mappings for this thingie. + + +-- Window size +vim.keymap.set('n','++','10+', {desc = 'Do 10 bigger in vertical size'}) +vim.keymap.set('n','--','10-', {desc = 'Do 10 smaller in vertical size'}) +vim.keymap.set('n','>>','10>', {desc = 'Do 10 bigger in horizontal size'}) +vim.keymap.set('n','<<','10<', {desc = 'Do 10 bigger in horizontal size'}) + +-- "In command line mode, and are more intelligent that and +-- ", because they remember the start of the command: that is +-- ":echo will go to commands that started with echo, instead of just the +-- "previous. +-- This should work, I don't understand why it doesn't. +-- vim.keymap.set('c',' ','wildmenumode() ? : ', {desc = 'If wildmenu then do down instead of c-n'}) +-- vim.keymap.set('c',' ','wildmenumode() ? : ', {desc = 'If wildmenu then do up instead of c-p'}) +vim.keymap.set('c','','', {desc = 'If wildmenu then do down instead of c-n'}) +vim.keymap.set('c','','', {desc = 'If wildmenu then do up instead of c-p'}) + +-- redraws the screen in normal mode, this redraws and eliminates highlight +vim.keymap.set('n','',':nohlsearch:diffupdate:syntax sync fromstart', {desc = 'Redraw and remove highlight'}) + +-- Save file +vim.keymap.set('n','wf',':w', {desc = 'Save file'}) + +-- Escape from insert mode with kj +-- Do not do this in visual mode (interferes with selection) +-- or command mode (doesn't allow searching for kj) +vim.keymap.set('i','kj',':w', {desc = 'Save file'}) + +-- Open help in vertical split in the Right +-- Combine vertical[vert] and botright[bo] commands +vim.keymap.set('n','vh',':vertical botright help', {desc = 'Vertical help'}) + +-- Syntax name for current word +-- nnoremap :echo "hightlight<" . synIDattr(synID(line("."),col("."),1),"name") . '> transparent<' +-- \ . synIDattr(synID(line("."),col("."),0),"name") . "> SyntaxId<" +-- \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" + +-- nnoremap fe /\\|\ +-- nnoremap st :Startify + +-- Switch horizontal split to vertical +-- Add R to rotate it at the end +vim.keymap.set('n','htv','tHR', {desc = 'Change horizontal split to vertical'}) + +-- Switch vertical split to horizontal +vim.keymap.set('n','vth','tKR', {desc = 'Change vertical split to horizontal'}) + +-- nnoremap mm :make +-- nnoremap ma :AsyncRun :make +-- nnoremap :AsyncRun cd\ $EMV_HOME\ &&\ bms\ build\ -b\ &&\ bms\ test + +-- Select inner word. +vim.keymap.set('n','','viw', {desc = 'Change vertical split to horizontal'}) + +-- #Navigate location list"""""""""""""""" +-- nmap ln :lne +-- nmap lp :lp +-- nnoremap vi{= +-- Buffers +vim.keymap.set('n','bn',':bn', {desc = 'Next buffer'}) +vim.keymap.set('n','bp',':bp', {desc = 'Previous buffer'}) +vim.keymap.set('n','bf',':bf', {desc = 'First buffer'}) +vim.keymap.set('n','bl',':bl', {desc = 'Last buffer'}) +vim.keymap.set('n','bd',':bd', {desc = 'Delete buffer'}) +-- Quickfix list +vim.keymap.set('n','cn',':cn', {desc = 'Next result'}) +vim.keymap.set('n','cp',':cp', {desc = 'Previous result'}) +vim.keymap.set('n','cf',':cfirst', {desc = 'First result'}) +vim.keymap.set('n','cl',':clast', {desc = 'Last result'}) +vim.keymap.set('n','co',':copen', {desc = 'Open quicfix list'}) +vim.keymap.set('n','cq',':cclose', {desc = 'Close quickfix list'}) +-- Location list +vim.keymap.set('n','ln',':lne', {desc = 'Change vertical split to horizontal'}) +vim.keymap.set('n','lp',':lp', {desc = 'Change vertical split to horizontal'}) + +-- Edit and source vimrc +vim.keymap.set('n','sv',':source $MYVIMRC', {desc = 'Source vimrc file'}) +vim.keymap.set('n','ev',':e $MYVIMRC', {desc = 'Change vimrc file'}) + +-- Make and recover default session. +vim.keymap.set('n','',': mksession! /home/$USER/.vim/files/nacho_vim_session', {desc = 'Make the default session'}) +vim.keymap.set('n','',': source! /home/$USER/.vim/files/nacho_vim_session', {desc = 'Source the default session'})