From ed116d02cf893106134a18e8d51c1fc174967bde Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sun, 25 Sep 2022 18:54:38 +0530 Subject: nvim autocompile C/C++ keymap --- .config/neofetch/config.conf | 2 +- .config/nvim/lua/justsaumit/keymaps.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.config/neofetch/config.conf b/.config/neofetch/config.conf index dd9fb8e..bfc857e 100644 --- a/.config/neofetch/config.conf +++ b/.config/neofetch/config.conf @@ -13,7 +13,7 @@ print_info() { info "Terminal emulator " term info "Theme " theme # info "Icons" icons - info "Terminal Font " term_font + info "Terminal Font " term_font info "CPU " cpu info "GPU﬙ " gpu info "Memoryﳔ " memory diff --git a/.config/nvim/lua/justsaumit/keymaps.lua b/.config/nvim/lua/justsaumit/keymaps.lua index 5b06bdc..f9fdcce 100644 --- a/.config/nvim/lua/justsaumit/keymaps.lua +++ b/.config/nvim/lua/justsaumit/keymaps.lua @@ -8,6 +8,17 @@ keymap("", "", "", opts) vim.g.mapleader = " " vim.g.maplocalleader = " " +---Autocompile and Execute +--ANSI C +vim.cmd([[autocmd BufEnter *.c map :w :!gcc % -ansi -o %< && ./%< ]]) +--C99 +vim.cmd([[autocmd BufEnter *.c map :w :!gcc -std=c99 % -o %< && ./%< ]]) +--C +vim.cmd([[autocmd BufEnter *.c map :w :!gcc % -o %< && ./%< ]]) + +--C++ +vim.cmd([[autocmd BufEnter *.cpp map :w :!g++ % -o %< && ./%< ]]) + -- Modes -- normal_mode = "n", -- insert_mode = "i", @@ -16,6 +27,8 @@ vim.g.maplocalleader = " " -- command_mode = "c", -- Normal -- +-- +-- --Save file with Ctrl+S keymap("n", "", ":w", opts) --Toggle nvim-tree @@ -57,3 +70,4 @@ keymap("x", "J", ":move '>+1gv-gv", opts) keymap("x", "K", ":move '<-2gv-gv", opts) keymap("x", "", ":move '>+1gv-gv", opts) keymap("x", "", ":move '<-2gv-gv", opts) + -- cgit v1.2.3