Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial for run code file #13

Closed
vnbubba opened this issue Feb 5, 2022 · 8 comments
Closed

Tutorial for run code file #13

vnbubba opened this issue Feb 5, 2022 · 8 comments

Comments

@vnbubba
Copy link

vnbubba commented Feb 5, 2022

Can you write a tutorial for running a code file as cpp, c file? Many thanks!

@kabinspace
Copy link
Member

@vnbubba I don't really program in c or cpp, can you tell me what would you like to know about them?

@vnbubba
Copy link
Author

vnbubba commented Feb 8, 2022

This is my keymap for run a C file as vimscript but I don't know how convert it to lua.
nnoremap <F5> :w <bar> !g++ -std=c++17 -O2 -Wall % -o %:r && %:r.exe <CR>

@hunger
Copy link
Contributor

hunger commented Feb 10, 2022

Try

map('n', '<f5>', ':w <bar> !g++ -std=c++17 -O2 -Wall % -o %:r && %:r.exe <CR>', opts)

map is the conveneince function that AstroVim defines for you, the 'n' is the mode (the first 'n' in "nnoremap") and opts be default set "noremap" and "silent" (the "noremap" is the part after the first n of "nnoremap").

Your old version is actually not marked up as silent, so you can try to replace the opts with { noremap = true } -- if that is important to you.

@kabinspace
Copy link
Member

@vnbubba Did the solution given by @hunger work for you?

@vnbubba
Copy link
Author

vnbubba commented Feb 16, 2022

@vnbubba Did the solution given by @hunger work for you?

image
May I missed something?

@hunger
Copy link
Contributor

hunger commented Feb 16, 2022

So the mapping worked and you only need to work on the code you want to call:-)

@vnbubba
Copy link
Author

vnbubba commented Feb 16, 2022

@vnbubba Did the solution given by @hunger work for you?
https://github.com/CRAG666/code_runner.nvim
https://github.com/skywind3000/asyncrun.vim
Can you add one of these packer for AstroVim? Thanks

@hunger
Copy link
Contributor

hunger commented Mar 18, 2022

There is no need to wait for AstroVim! You can just add all the plugins you need yourself:-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants