From 8d7e57f64b4d2d88cb50fafebc88c309d0ba6571 Mon Sep 17 00:00:00 2001 From: Beau McCartney Date: Sun, 5 Jan 2025 13:06:32 -0700 Subject: [PATCH 1/2] vim compiler plugin for ghostty filetype - validates config `:make` will call `ghostty +validate-config` and populate the quickfix list with the errors that can be navigated to (e.g. with `:cnext`) `:h write-compiler-plugin`, and neovim's built in ftplugin/ and compiler/ plugins were used as references --- build.zig | 2 ++ src/config/vim.zig | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/build.zig b/build.zig index d92d3e719f..09b029f6f3 100644 --- a/build.zig +++ b/build.zig @@ -615,6 +615,7 @@ pub fn build(b: *std.Build) !void { _ = wf.add("syntax/ghostty.vim", config_vim.syntax); _ = wf.add("ftdetect/ghostty.vim", config_vim.ftdetect); _ = wf.add("ftplugin/ghostty.vim", config_vim.ftplugin); + _ = wf.add("compiler/ghostty.vim", config_vim.compiler); b.installDirectory(.{ .source_dir = wf.getDirectory(), .install_dir = .prefix, @@ -631,6 +632,7 @@ pub fn build(b: *std.Build) !void { _ = wf.add("syntax/ghostty.vim", config_vim.syntax); _ = wf.add("ftdetect/ghostty.vim", config_vim.ftdetect); _ = wf.add("ftplugin/ghostty.vim", config_vim.ftplugin); + _ = wf.add("compiler/ghostty.vim", config_vim.compiler); b.installDirectory(.{ .source_dir = wf.getDirectory(), .install_dir = .prefix, diff --git a/src/config/vim.zig b/src/config/vim.zig index d048fc9902..00836cd40b 100644 --- a/src/config/vim.zig +++ b/src/config/vim.zig @@ -24,6 +24,21 @@ pub const ftplugin = \\ \\let b:undo_ftplugin = 'setl cms< isk< ofu<' \\ + \\if !exists('current_compiler') + \\ compiler ghostty + \\ let b:undo_ftplugin .= "| compiler make" + \\endif + \\ +; +pub const compiler = + \\if exists("current_compiler") + \\ finish + \\endif + \\let current_compiler = "ghostty" + \\ + \\CompilerSet makeprg=ghostty\ +validate-config + \\CompilerSet errorformat=%f:%l:%m + \\ ; /// Generates the syntax file at comptime. From 94bf448eda7e3855e5973acd0674550458a08c4e Mon Sep 17 00:00:00 2001 From: Beau McCartney Date: Sun, 5 Jan 2025 17:08:52 -0700 Subject: [PATCH 2/2] just reset makeprg and errorformat --- src/config/vim.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/vim.zig b/src/config/vim.zig index 00836cd40b..62255bd79a 100644 --- a/src/config/vim.zig +++ b/src/config/vim.zig @@ -26,7 +26,7 @@ pub const ftplugin = \\ \\if !exists('current_compiler') \\ compiler ghostty - \\ let b:undo_ftplugin .= "| compiler make" + \\ let b:undo_ftplugin .= " makeprg< errorformat<" \\endif \\ ;