Skip to content

Commit bc824e5

Browse files
authored
Merge pull request #77 from saccarosium/chores
Chores
2 parents 825a0d5 + 196c137 commit bc824e5

File tree

2 files changed

+105
-108
lines changed

2 files changed

+105
-108
lines changed

Diff for: .editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[*.md]
10+
trim_trailing_whitespace = false

Diff for: README.md

+95-108
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,30 @@ When I was still in college it was common to try multiple programming languages,
1818

1919
```lua
2020
require("lazy").setup({
21-
{"CRAG666/code_runner.nvim", config = true },
21+
{ "CRAG666/code_runner.nvim", config = true },
2222
}
2323
```
2424

2525
- With [packer.nvim](https://github.com/wbthomason/packer.nvim)
2626

2727
```lua
28-
use { 'CRAG666/code_runner.nvim', requires = 'nvim-lua/plenary.nvim' }
28+
use {
29+
'CRAG666/code_runner.nvim',
30+
requires = 'nvim-lua/plenary.nvim'
31+
}
2932
```
3033

31-
Consider using [CRAG666/betterTerm.nvim](https://github.com/CRAG666/betterTerm.nvim)
32-
33-
require("harpoon.term").sendCommand(1, require("code_runner.commands").get_filetype_command() .. "\n")
34-
3534
- With [paq-nvim](https://github.com/savq/paq-nvim)
3635

3736
```lua
38-
require "paq"{'CRAG666/code_runner.nvim'; 'nvim-lua/plenary.nvim';}
37+
require "paq"{
38+
'CRAG666/code_runner.nvim';
39+
'nvim-lua/plenary.nvim';
40+
}
3941
```
4042

43+
Consider using [CRAG666/betterTerm.nvim](https://github.com/CRAG666/betterTerm.nvim)
44+
4145
### Quick start
4246

4347
Add the following line to your init.lua
@@ -69,25 +73,21 @@ Don't use setup if filetype or a json path
6973
- Toggle runner
7074
- Reload runner
7175
- Run in a Float window
72-
- Run in a buffer
7376
- Run in a tab
7477
- Run in a split
7578
- Run in toggleTerm
7679

77-
##### Help build this feature
78-
79-
The things to do are listed below:
80-
81-
- Open an issue to know if it is worth implementing this function and if there are people interested in its existence
80+
> **Note**
81+
> If you want implement a new feature open an issue to know if it is worth implementing it and if there are people interested.
8282
8383
### Functions
8484

8585
All run commands allow restart. So, for example, if you use a command that does not have hot reload, you can call a command again and it will close the previous one and start again.
8686

8787
- `:RunCode` - Runs based on file type, first checking if belongs to project, then if filetype mapping exists
8888
- `:RunCode <A_key_here>` - Execute command from its key in current directory.
89-
- `:RunFile <mode>` - Run the current file(optionally you can select an opening mode: {"toggle", "float", "tab", "toggleterm", "buf"}, default: "term").
90-
- `:RunProject <mode>` - Run the current project(If you are in a project otherwise you will not do anything, (optionally you can select an opening mode: {"toggle", "float", "tab", "toggleterm", "buf"}, default: "term").
89+
- `:RunFile <mode>` - Run the current file(optionally you can select an opening mode: {"toggle", "float", "tab", "toggleterm"}, default: "term").
90+
- `:RunProject <mode>` - Run the current project(If you are in a project otherwise you will not do anything, (optionally you can select an opening mode: {"toggle", "float", "tab", "toggleterm"}, default: "term").
9191
- `:RunClose` - Close runner
9292
- `:CRFiletype` - Open json with supported files(Use only if you configured with json files).
9393
- `:CRProjects` - Open json with list of projects(Use only if you configured with json files).
@@ -108,35 +108,26 @@ vim.keymap.set('n', '<leader>crp', ':CRProjects<CR>', { noremap = true, silent =
108108

109109
### Options
110110

111-
- `mode`: Mode in which you want to run(default: term, valid options: {"toggle", "float", "tab", "toggleterm", "buf"}),
111+
- `mode`: Mode in which you want to run(default: term, valid options: `{"toggle", "float", "tab", "toggleterm", "buf"}`),
112112
- `focus`: Focus on runner window(only works on toggle, term and tab mode, default: true)
113113
- `startinsert`: init in insert mode(default: false)
114114
- `term`: Configurations for the integrated terminal
115115
Fields:
116-
117116
- `position`: Integrated terminal position(for option :h windows, default: `belowright`)
118117
- `size`: Size of the terminal window (default: `8`)
119-
120118
- `float`: Configurations for the float win
121-
Fields:
122-
123-
- `border`: Window border (see ':h nvim_open_win')
119+
- `border`: Window border (see `:h nvim_open_win`)
124120
- `height`
125121
- `width`
126122
- `x`
127123
- `y`
128124
- `border_hl`: (default: FloatBorder)
129125
- `float_hl`: (defult: "Normal")
130-
- `blend`: Transparency (see ':h winblend')
131-
126+
- `blend`: Transparency (see `:h winblend`)
132127
- `before_run_filetype`: Execute before executing a file(type func)
133-
134128
- `filetype_path`: Absolute path to json file config (default: "", use absolute paths)
135-
136129
- `filetype`: If you prefer to use lua instead of json files, you can add your settings by file type here(type table)
137-
138130
- `project_path`: Absolute path to json file config (default: "", use absolute paths)
139-
140131
- `project`: If you prefer to use lua instead of json files, you can add your settings by project here(type table)
141132

142133
### Setup
@@ -148,11 +139,11 @@ require('code_runner').setup {
148139
focus = false,
149140
startinsert = true,
150141
term = {
151-
position = "vert",
152-
size = 8,
153-
},
154-
filetype_path = vim.fn.expand('~/.config/nvim/code_runner.json'),
155-
project_path = vim.fn.expand('~/.config/nvim/project_manager.json')
142+
position = "vert",
143+
size = 8,
144+
},
145+
filetype_path = vim.fn.expand('~/.config/nvim/code_runner.json'),
146+
project_path = vim.fn.expand('~/.config/nvim/project_manager.json')
156147
}
157148
```
158149

@@ -235,37 +226,37 @@ It is important that you know that configuration is given priority in pure lua,
235226
require('code_runner').setup {
236227
mode = "term",
237228
startinsert = true,
238-
term = {
239-
position = "vert",
240-
size = 15,
241-
},
242-
filetype = {
243-
java = {
244-
"cd $dir &&",
245-
"javac $fileName &&",
246-
"java $fileNameWithoutExt"
247-
},
248-
python = "python3 -u",
249-
typescript = "deno run",
250-
rust = {
251-
"cd $dir &&",
252-
"rustc $fileName &&",
253-
"$dir$fileNameWithoutExt"
254-
},
255-
},
256-
project = {
257-
["~/deno/example"] = {
258-
name = "ExapleDeno",
259-
description = "Project with deno using other command",
260-
file_name = "http/main.ts",
261-
command = "deno run --allow-net"
262-
},
263-
["~/cpp/example"] = {
264-
name = "ExapleCpp",
265-
description = "Project with make file",
266-
command = "make buid && cd buid/ && ./compiled_file"
267-
}
268-
},
229+
term = {
230+
position = "vert",
231+
size = 15,
232+
},
233+
filetype = {
234+
java = {
235+
"cd $dir &&",
236+
"javac $fileName &&",
237+
"java $fileNameWithoutExt"
238+
},
239+
python = "python3 -u",
240+
typescript = "deno run",
241+
rust = {
242+
"cd $dir &&",
243+
"rustc $fileName &&",
244+
"$dir$fileNameWithoutExt"
245+
},
246+
},
247+
project = {
248+
["~/deno/example"] = {
249+
name = "ExapleDeno",
250+
description = "Project with deno using other command",
251+
file_name = "http/main.ts",
252+
command = "deno run --allow-net"
253+
},
254+
["~/cpp/example"] = {
255+
name = "ExapleCpp",
256+
description = "Project with make file",
257+
command = "make buid && cd buid/ && ./compiled_file"
258+
}
259+
},
269260
}
270261
```
271262

@@ -289,26 +280,26 @@ The file should look like this(the default file does not exist create it with th
289280
#### Configure with lua files
290281

291282
```lua
292-
..... more config .....
293-
filetype = {
283+
-- ..... more config .....
284+
filetype = {
294285
java = {
295286
"cd $dir &&",
296287
"javac $fileName &&",
297288
"java $fileNameWithoutExt"
298289
},
299-
python = "python3 -u",
300-
typescript = "deno run",
290+
python = "python3 -u",
291+
typescript = "deno run",
301292
rust = {
302293
"cd $dir &&",
303294
"rustc $fileName &&",
304295
"$dir$fileNameWithoutExt"
305296
},
306297
},
307-
..... more config .....
298+
-- ..... more config .....
308299
}
309300
```
310301

311-
if you want to add some other language or some other command follow this structure "key": "commans"
302+
if you want to add some other language or some other command follow this structure `key`: `commans`
312303

313304
#### Variables
314305

@@ -322,12 +313,12 @@ The available variables are the following:
322313

323314
Below is an example of an absolute path and how it behaves depending on the variable:
324315

325-
absolute path: /home/anyuser/current/file.py
316+
absolute path: `/home/anyuser/current/file.py`
326317

327-
- `file` = /home/anyuser/current/file.py
328-
- `fileName` = file.py
329-
- `fileNameWithoutExt` = file
330-
- `dir` = /home/anyuser/current
318+
- `file` = `/home/anyuser/current/file.py`
319+
- `fileName` = `file.py`
320+
- `fileNameWithoutExt` = `file`
321+
- `dir` = `/home/anyuser/current`
331322

332323
Remember that if you don't want to use variables you can use vim [filename-modifiers](http://vimdoc.sourceforge.net/htmldoc/cmdline.html#filename-modifiers)
333324

@@ -339,19 +330,19 @@ json:
339330

340331
```json
341332
{
342-
....... more ........
343-
"javascript": "node",
344-
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"
333+
# ....... more ........
334+
"javascript": "node",
335+
"objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"
345336
}
346337
```
347338

348339
lua:
349340

350341
```lua
351342
{
352-
....... more ........
353-
javascript = "node",
354-
["objective-c"] = "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"
343+
-- ....... more ........
344+
javascript = "node",
345+
["objective-c"] = "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt"
355346
}
356347
```
357348

@@ -389,47 +380,46 @@ The file should look like this(the default file does not exist create it with th
389380
#### Configure with lua files
390381

391382
```lua
392-
..... more config .....
393-
project = {
394-
["~/python/intel_2021_1"] = {
395-
name = "Intel Course 2021",
396-
description = "Simple python project",
397-
file_name = "POO/main.py"
398-
},
399-
["~/deno/example"] = {
400-
name = "ExapleDeno",
401-
description = "Project with deno using other command",
402-
file_name = "http/main.ts",
403-
command = "deno run --allow-net"
404-
},
405-
["~/cpp/example"] = {
406-
name = "ExapleCpp",
407-
description = "Project with make file",
408-
command = "make buid && cd buid/ && ./compiled_file"
409-
}
383+
-- ..... more config .....
384+
project = {
385+
["~/python/intel_2021_1"] = {
386+
name = "Intel Course 2021",
387+
description = "Simple python project",
388+
file_name = "POO/main.py"
389+
},
390+
["~/deno/example"] = {
391+
name = "ExapleDeno",
392+
description = "Project with deno using other command",
393+
file_name = "http/main.ts",
394+
command = "deno run --allow-net"
395+
},
396+
["~/cpp/example"] = {
397+
name = "ExapleCpp",
398+
description = "Project with make file",
399+
command = "make buid && cd buid/ && ./compiled_file"
400+
}
410401
},
411-
..... more config .....
412-
}
402+
-- ..... more config .....
413403
```
414404

415405
There are 3 main ways to configure the execution of a project (found in the example.)
416406

417407
1. Use the default command defined in the filetypes file (see `:CRFiletype`or check your confi lua). In order to do that it is necessary to define file_name.
418-
419408
2. Use a different command than the one set in `CRFiletype` or your config lua. In this case, the file_name and command must be provided.
420-
421409
3. Use a command to run the project. It is only necessary to define command(You do not need to write navigate to the root of the project, because automatically the plugin is located in the root of the project).
422410

423411
Note: Don't forget to name your projects because if you don't do so code runner will fail as it uses the name for the buffer name
424412

425413
#### Projects parameters
426414

415+
> **Warning**
416+
> Avoid using all the parameters at the same time. The correct way to use them is shown in the example and described above.
417+
427418
- `name`: Project name
428419
- `description`: Project description
429420
- `file_name`: Filename relative to root path
430421
- `command`: Command to run the project. It is possible to use variables exactly the same as we would in `CRFiletype`
431422

432-
warning! : Avoid using all the parameters at the same time. The correct way to use them is shown in the example and described above.
433423

434424
### Queries
435425

@@ -467,9 +457,7 @@ For unknown reasons, leaving a comma in the trailing element in any json file ca
467457
# Inspirations and thanks
468458

469459
- The idea of this project comes from the vscode plugin [code_runner](https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner) You can even copy your configuration and pass it to this plugin, as they are the same in the way of defining commands associated with [filetypes](https://github.com/CRAG666/code_runner.nvim#add-support-for-more-file-types)
470-
471460
- [jaq-nvim](https://github.com/is0n/jaq-nvim) some ideas of how to execute commands were taken from this plugin, thank you very much.
472-
473461
- [FTerm.nvim](https://github.com/numToStr/FTerm.nvim) Much of how this README.md is structured was blatantly stolen from this plugin, thank you very much
474462

475463
- Thanks to all current and future collaborators, without their contributions this plugin would not be what it is today
@@ -486,9 +474,8 @@ For unknown reasons, leaving a comma in the trailing element in any json file ca
486474

487475
Your help is needed to make this plugin the best of its kind, be free to contribute, criticize (don't be soft) or contribute ideas. All PR's are welcome.
488476

489-
## :warning: Important!
490-
491-
If you have any ideas to improve this project, do not hesitate to make a request, if problems arise, try to solve them and publish them. Don't be so picky I did this in one afternoon
477+
> **Note**
478+
> If you have any ideas to improve this project, do not hesitate to make a request, if problems arise, try to solve them and publish them. Don't be so picky I did this in one afternoon
492479
493480
# LICENCE
494481

0 commit comments

Comments
 (0)