Improving command parsing semantics, gofmt, warn when command reported
This commit is contained in:
@@ -3,17 +3,17 @@
|
|||||||
|
|
||||||
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
|
||||||
- Add Bool variable
|
- Add Bool variable
|
||||||
- Not rendering U+0009 TAB properly
|
- SetWorkDir should rewrite the buffer name paths for special buffers
|
||||||
|
|
||||||
- Initialize all keybindings at the start and refer using global variables?
|
- Initialize all keybindings at the start and refer using global variables?
|
||||||
- RegisterCommand should_appear_in_listing variable
|
- RegisterCommand should_appear_in_listing variable
|
||||||
- Maybe one list for all variables including the commands etc?
|
- Maybe one list for all variables including the commands etc?
|
||||||
- Problem generating configs don't know which quotation marks would be good ....
|
|
||||||
|
|
||||||
Use session 3:
|
Use session 3:
|
||||||
- Maybe status view, commit changes (like to buffer name or line) on enter?
|
- Maybe status view, commit changes (like to buffer name or line) on enter?
|
||||||
|
|
||||||
How to go about search/replace, opening code and other considerations
|
How to go about search/replace, opening code and other considerations
|
||||||
|
- Search and replace sign Find@>ReplaceWith
|
||||||
- We can use sed + find to search and replace, the automatic reopen should do the job
|
- We can use sed + find to search and replace, the automatic reopen should do the job
|
||||||
- Maybe also we can List all files recursively instead of opening them, how fast is that???
|
- Maybe also we can List all files recursively instead of opening them, how fast is that???
|
||||||
- For fuzzy find number of files is the problem - most likely just getting them in one place is the biggest problem that can be optimized
|
- For fuzzy find number of files is the problem - most likely just getting them in one place is the biggest problem that can be optimized
|
||||||
|
|||||||
@@ -1515,10 +1515,16 @@ void ReopenBuffer(Buffer *buffer) {
|
|||||||
|
|
||||||
void SaveBuffer(Buffer *buffer) {
|
void SaveBuffer(Buffer *buffer) {
|
||||||
bool formatted = false;
|
bool formatted = false;
|
||||||
if (FormatUsingClangFormatWhenCCode) {
|
if (FormatCode) {
|
||||||
bool c = EndsWith(buffer->name, ".c") || EndsWith(buffer->name, ".cpp") || EndsWith(buffer->name, ".h") || EndsWith(buffer->name, ".hpp");
|
bool c = EndsWith(buffer->name, ".c") || EndsWith(buffer->name, ".cpp") || EndsWith(buffer->name, ".h") || EndsWith(buffer->name, ".hpp");
|
||||||
if (c) {
|
if (c) {
|
||||||
ApplyClangFormat(buffer);
|
ApplyFormattingTool(buffer, "clang-format");
|
||||||
|
formatted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool go = EndsWith(buffer->name, ".go");
|
||||||
|
if (go) {
|
||||||
|
ApplyFormattingTool(buffer, "gofmt");
|
||||||
formatted = true;
|
formatted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -316,10 +316,10 @@ void ConvertLineEndingsToLF(Buffer *buffer, bool trim_lines_with_caret = false)
|
|||||||
view->update_scroll = false;
|
view->update_scroll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyClangFormat(Buffer *buffer) {
|
void ApplyFormattingTool(Buffer *buffer, String tool) {
|
||||||
Scratch scratch;
|
Scratch scratch;
|
||||||
String string = AllocCharString(scratch, buffer);
|
String string = AllocCharString(scratch, buffer);
|
||||||
Buffer *temp_buffer = ExecAndWait(scratch, "clang-format", GetDir(buffer), string);
|
Buffer *temp_buffer = ExecAndWait(scratch, tool, GetDir(buffer), string);
|
||||||
ReplaceWithoutMovingCarets(buffer, GetRange(buffer), {temp_buffer->str, temp_buffer->len});
|
ReplaceWithoutMovingCarets(buffer, GetRange(buffer), {temp_buffer->str, temp_buffer->len});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +468,14 @@ ResolvedOpen ResolveOpen(Allocator alo, String path, String meta) {
|
|||||||
{
|
{
|
||||||
if (StartsWith(path, ":")) {
|
if (StartsWith(path, ":")) {
|
||||||
result.kind = OpenKind_Command;
|
result.kind = OpenKind_Command;
|
||||||
result.path = Skip(path, 1);
|
path = Skip(path, 1);
|
||||||
|
result.path.data = path.data;
|
||||||
|
for (Int i = 0; i < path.len; i += 1) {
|
||||||
|
if (IsNonWord(path.data[i])) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result.path.len += 1;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -682,13 +689,16 @@ void CMD_ToggleFullscreen() {
|
|||||||
} RegisterCommand(CMD_ToggleFullscreen, "f11");
|
} RegisterCommand(CMD_ToggleFullscreen, "f11");
|
||||||
|
|
||||||
void CMD_SetWorkDir() {
|
void CMD_SetWorkDir() {
|
||||||
|
Scratch scratch;
|
||||||
BSet main = GetBSet(LastActiveLayoutWindowID);
|
BSet main = GetBSet(LastActiveLayoutWindowID);
|
||||||
WorkDir = GetDir(main.buffer);
|
WorkDir = GetDir(main.buffer);
|
||||||
|
For (Buffers) {
|
||||||
|
String name = SkipToLastSlash(it->name);
|
||||||
|
it->name = Intern(&GlobalInternTable, Format(scratch, "%S/%S", WorkDir, name));
|
||||||
|
}
|
||||||
} RegisterCommand(CMD_SetWorkDir, "");
|
} RegisterCommand(CMD_SetWorkDir, "");
|
||||||
|
|
||||||
String CodeSkipPatterns[] = {".git/", ".obj", ".o", ".pdb", ".exe", "SDL/", ".ilk", ".ttf", ".ico", ".gif"};
|
|
||||||
String Coro_OpenCodeDir;
|
String Coro_OpenCodeDir;
|
||||||
|
|
||||||
void Coro_OpenCode(mco_coro *co) {
|
void Coro_OpenCode(mco_coro *co) {
|
||||||
Array<String> patterns = Split(CoCurr->arena, NonCodePatterns_EndsWith, "|");
|
Array<String> patterns = Split(CoCurr->arena, NonCodePatterns_EndsWith, "|");
|
||||||
Array<String> dirs = {CoCurr->arena};
|
Array<String> dirs = {CoCurr->arena};
|
||||||
@@ -1381,6 +1391,7 @@ void Set(String16 string) {
|
|||||||
void CMD_Set() {
|
void CMD_Set() {
|
||||||
BSet set = GetBSet(ActiveWindowID);
|
BSet set = GetBSet(ActiveWindowID);
|
||||||
Range range = set.view->carets[0].range;
|
Range range = set.view->carets[0].range;
|
||||||
|
range.max = range.min; // We only scan for :Set
|
||||||
if (GetSize(range) == 0) {
|
if (GetSize(range) == 0) {
|
||||||
range = EncloseLoadWord(set.buffer, range.min);
|
range = EncloseLoadWord(set.buffer, range.min);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,4 +162,4 @@ RegisterVariable(Float, JumpHistoryMergeTime, 0.3);
|
|||||||
RegisterVariable(String, InternetBrowser, "firefox");
|
RegisterVariable(String, InternetBrowser, "firefox");
|
||||||
RegisterVariable(String, NonCodePatterns_EndsWith, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall");
|
RegisterVariable(String, NonCodePatterns_EndsWith, ".git/|.obj|.o|.pdb|.exe|.ilk|.ttf|.ico|.gif|.jpg|.png|.spall");
|
||||||
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||||
RegisterVariable(Int, FormatUsingClangFormatWhenCCode, 0);
|
RegisterVariable(Int, FormatCode, 0);
|
||||||
@@ -460,6 +460,7 @@ void EvalCommand(String command) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ReportErrorf("Failed to match with any of the commands: %S", command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EvalCommand(String16 command) {
|
void EvalCommand(String16 command) {
|
||||||
|
|||||||
@@ -196,4 +196,4 @@ struct ResolvedOpen {
|
|||||||
ResolvedOpen ResolveOpen(Allocator scratch, String path, String meta);
|
ResolvedOpen ResolveOpen(Allocator scratch, String path, String meta);
|
||||||
void CenterView(WindowID window);
|
void CenterView(WindowID window);
|
||||||
void TrimWhitespace(Buffer *buffer, bool trim_lines_with_caret = false);
|
void TrimWhitespace(Buffer *buffer, bool trim_lines_with_caret = false);
|
||||||
void ApplyClangFormat(Buffer *buffer);
|
void ApplyFormattingTool(Buffer *buffer, String tool);
|
||||||
Reference in New Issue
Block a user