summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2022-09-25 18:54:38 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2022-09-25 18:54:38 +0530
commited116d02cf893106134a18e8d51c1fc174967bde (patch)
treed03d16c1d2f69a3d6b7ff2bb1cb44d8610057a17
parent3de96d686d7b85ff22246663932c708bc6357e51 (diff)
nvim autocompile C/C++ keymap
-rw-r--r--.config/neofetch/config.conf2
-rw-r--r--.config/nvim/lua/justsaumit/keymaps.lua14
2 files changed, 15 insertions, 1 deletions
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("", "<Space>", "<Nop>", opts)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
+---Autocompile and Execute
+--ANSI C
+vim.cmd([[autocmd BufEnter *.c map <F4> :w <CR> :!gcc % -ansi -o %< && ./%< <CR>]])
+--C99
+vim.cmd([[autocmd BufEnter *.c map <F5> :w <CR> :!gcc -std=c99 % -o %< && ./%< <CR>]])
+--C
+vim.cmd([[autocmd BufEnter *.c map <F6> :w <CR> :!gcc % -o %< && ./%< <CR>]])
+
+--C++
+vim.cmd([[autocmd BufEnter *.cpp map <F4> :w <CR> :!g++ % -o %< && ./%< <CR>]])
+
-- 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", "<C-s>", ":w<CR>", opts)
--Toggle nvim-tree
@@ -57,3 +70,4 @@ keymap("x", "J", ":move '>+1<CR>gv-gv", opts)
keymap("x", "K", ":move '<-2<CR>gv-gv", opts)
keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts)
keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts)
+