From 45443be1bc30220da36306643646720ccf0d2ee9 Mon Sep 17 00:00:00 2001 From: Keita Haga <keitahaga@mail.com> Date: Sun, 20 Mar 2011 16:12:24 +0900 Subject: [PATCH 1/9] misc/vim/syntax/factor.vim: set 'shiftwidth' option in modeline --- misc/factor.vim.fgen | 2 +- misc/vim/syntax/factor.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/factor.vim.fgen b/misc/factor.vim.fgen index 57a518ae11..0d446420cc 100644 --- a/misc/factor.vim.fgen +++ b/misc/factor.vim.fgen @@ -317,4 +317,4 @@ endif let b:current_syntax = "factor" -" vim: syntax=vim +" vim:set ft=vim sw=4: diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index df4e249af2..8e827368b7 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -304,4 +304,4 @@ endif let b:current_syntax = "factor" -" vim: syntax=vim +" vim:set ft=vim sw=4: From 45d9f231040642bfa22b1e8c8a505f573bf4dc58 Mon Sep 17 00:00:00 2001 From: Keita Haga <keitahaga@mail.com> Date: Sun, 20 Mar 2011 17:37:50 +0900 Subject: [PATCH 2/9] misc/vim/syntax/factor.vim: add support for escape characters --- misc/factor.vim.fgen | 8 +++++--- misc/vim/syntax/factor.vim | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/misc/factor.vim.fgen b/misc/factor.vim.fgen index 0d446420cc..340f9e374e 100644 --- a/misc/factor.vim.fgen +++ b/misc/factor.vim.fgen @@ -12,7 +12,7 @@ IN: factor.vim.fgen " Vim syntax file " Language: Factor " Maintainer: Alex Chapman <chapman.alex@gmail.com> -" Last Change: 2011 Mar 18 +" Last Change: 2011 Mar 20 " To run: USING: html.templates html.templates.fhtml ; "resource:misc/factor.vim.fgen" <fhtml> call-template " For version 5.x: Clear all syntax items @@ -150,8 +150,9 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle " LIBRARY: "#\ " -syn region factorString start=/\<"/ skip=/\\"/ end=/"/ -syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ +syn match factorEscape /\\\(\\\|s\|t\|n\|r\|0\|e\|\"\|u\x\{6\}\|u{\S\+}\)/ contained +syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape +syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/ syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents @@ -235,6 +236,7 @@ if version >= 508 || !exists("did_factor_syn_inits") HiLink factorPrivateMethodDelims Special HiLink factorPGenericDelims Special HiLink factorPGenericNDelims Special + HiLink factorEscape SpecialChar HiLink factorString String HiLink factorTriString String HiLink factorSbuf String diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 8e827368b7..1f0f15528f 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Factor " Maintainer: Alex Chapman <chapman.alex@gmail.com> -" Last Change: 2011 Mar 18 +" Last Change: 2011 Mar 20 " To run: USING: html.templates html.templates.fhtml ; "resource:misc/factor.vim.fgen" <fhtml> call-template " For version 5.x: Clear all syntax items @@ -137,8 +137,9 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle " LIBRARY: "#\ " -syn region factorString start=/\<"/ skip=/\\"/ end=/"/ -syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ +syn match factorEscape /\\\(\\\|s\|t\|n\|r\|0\|e\|\"\|u\x\{6\}\|u{\S\+}\)/ contained +syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape +syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/ syn region factorMultiString matchgroup=factorMultiStringDelims start=/\<STRING:\s\+\S\+\>/ end=/^;$/ contains=factorMultiStringContents @@ -222,6 +223,7 @@ if version >= 508 || !exists("did_factor_syn_inits") HiLink factorPrivateMethodDelims Special HiLink factorPGenericDelims Special HiLink factorPGenericNDelims Special + HiLink factorEscape SpecialChar HiLink factorString String HiLink factorTriString String HiLink factorSbuf String From d1b126f15bec2b4159dd3d090657ec58d954509d Mon Sep 17 00:00:00 2001 From: Keita Haga <keitahaga@mail.com> Date: Mon, 21 Mar 2011 05:33:13 +0900 Subject: [PATCH 3/9] misc/vim/syntax/factor.vim: factorEscape cleanup --- misc/factor.vim.fgen | 4 ++-- misc/vim/syntax/factor.vim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/factor.vim.fgen b/misc/factor.vim.fgen index 340f9e374e..fe51deb37a 100644 --- a/misc/factor.vim.fgen +++ b/misc/factor.vim.fgen @@ -12,7 +12,7 @@ IN: factor.vim.fgen " Vim syntax file " Language: Factor " Maintainer: Alex Chapman <chapman.alex@gmail.com> -" Last Change: 2011 Mar 20 +" Last Change: 2011 Mar 21 " To run: USING: html.templates html.templates.fhtml ; "resource:misc/factor.vim.fgen" <fhtml> call-template " For version 5.x: Clear all syntax items @@ -150,7 +150,7 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle " LIBRARY: "#\ " -syn match factorEscape /\\\(\\\|s\|t\|n\|r\|0\|e\|\"\|u\x\{6\}\|u{\S\+}\)/ contained +syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6\}\|u{\S\+}\)/ contained syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/ diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 1f0f15528f..404b640c8e 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -1,7 +1,7 @@ " Vim syntax file " Language: Factor " Maintainer: Alex Chapman <chapman.alex@gmail.com> -" Last Change: 2011 Mar 20 +" Last Change: 2011 Mar 21 " To run: USING: html.templates html.templates.fhtml ; "resource:misc/factor.vim.fgen" <fhtml> call-template " For version 5.x: Clear all syntax items @@ -137,7 +137,7 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle " LIBRARY: "#\ " -syn match factorEscape /\\\(\\\|s\|t\|n\|r\|0\|e\|\"\|u\x\{6\}\|u{\S\+}\)/ contained +syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6\}\|u{\S\+}\)/ contained syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/ From f77bb075258adb9b61fc96eba32374d00c8f5b00 Mon Sep 17 00:00:00 2001 From: Keita Haga <keitahaga@mail.com> Date: Mon, 21 Mar 2011 06:52:10 +0900 Subject: [PATCH 4/9] misc/vim/syntax/factor.vim: add 'display' argument to factorEscape highlight group --- misc/factor.vim.fgen | 2 +- misc/vim/syntax/factor.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/factor.vim.fgen b/misc/factor.vim.fgen index fe51deb37a..7dcf59142d 100644 --- a/misc/factor.vim.fgen +++ b/misc/factor.vim.fgen @@ -150,7 +150,7 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle " LIBRARY: "#\ " -syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6\}\|u{\S\+}\)/ contained +syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6}\|u{\S\+}\)/ contained display syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/ diff --git a/misc/vim/syntax/factor.vim b/misc/vim/syntax/factor.vim index 404b640c8e..35b7a4c253 100644 --- a/misc/vim/syntax/factor.vim +++ b/misc/vim/syntax/factor.vim @@ -137,7 +137,7 @@ syn cluster factorWordOps contains=factorConstant,factorAlias,factorSingle " LIBRARY: "#\ " -syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6\}\|u{\S\+}\)/ contained +syn match factorEscape /\\\([\\stnr0e\"]\|u\x\{6}\|u{\S\+}\)/ contained display syn region factorString start=/\<"/ skip=/\\"/ end=/"/ contains=factorEscape syn region factorTriString start=/\<"""/ skip=/\\"/ end=/"""/ contains=factorEscape syn region factorSbuf start=/\<[-a-zA-Z0-9]\+"\>/ skip=/\\"/ end=/"/ From ef76c7b210bf0c1427a4244726e51d62f64c848b Mon Sep 17 00:00:00 2001 From: Keita Haga <keitahaga@mail.com> Date: Thu, 24 Mar 2011 09:18:46 +0900 Subject: [PATCH 5/9] Replace misc/vim/README with misc/vim/README.md --- misc/vim/README | 64 ------------------------------------ misc/vim/README.md | 81 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 64 deletions(-) delete mode 100644 misc/vim/README create mode 100644 misc/vim/README.md diff --git a/misc/vim/README b/misc/vim/README deleted file mode 100644 index db7e4f09a3..0000000000 --- a/misc/vim/README +++ /dev/null @@ -1,64 +0,0 @@ -Vim support for Factor ----------------------- - -This directory contains various support files that make editing Factor code -more pleasant in Vim. The file-layout exactly matches the Vim runtime -structure, so you can install them by copying the contents of this directory -into ~/.vim/ or the equivalent path on other platforms (Open Vim and type -":help 'runtimepath'" for details). - -The current set of files is as follows: - - ftdetect/factor.vim - Teach Vim when to load Factor support files. - ftplugin/factor_settings.vim - Teach Vim to follow the Factor Coding Style guidelines. - plugin/factor.vim - Teach Vim some commands for navigating Factor source code. See below. - syntax/factor.vim - Syntax highlighting for Factor code. - -The "plugin/factor.vim" file implements the following commands for -navigating Factor source: - - :FactorVocab factor.vocab.name - Opens the source file implementing the "factor.vocab.name" - vocabulary. - :NewFactorVocab factor.vocab.name - Creates a new factor vocabulary under the working vocabulary root. - :FactorVocabImpl - Opens the main implementation file for the current vocabulary - (name.factor). The keyboard shortcut "\fi" is bound to this - command. - :FactorVocabDocs - Opens the documentation file for the current vocabulary - (name-docs.factor). The keyboard shortcut "\fd" is bound to this - command. - :FactorVocabTests - Opens the unit test file for the current vocabulary - (name-tests.factor). The keyboard shortcut "\ft" is bound to this - command. - -In order for the ":FactorVocab" command to work, you'll need to set some -variables in your vimrc file: - g:FactorRoot - This variable should be set to the root of your Factor - installation. The default value is "~/factor". - g:FactorVocabRoots - This variable should be set to a list of Factor vocabulary roots. - The paths may be either relative to g:FactorRoot or absolute paths. - The default value is ["core", "basis", "extra", "work"]. - g:FactorNewVocabRoot - This variable should be set to the vocabulary root in which - vocabularies created with NewFactorVocab should be created. The - default value is "work". - -Note: The syntax-highlighting file is automatically generated to include the -names of all the vocabularies Factor knows about. To regenerate it manually, -run the following code in the listener: - - "editors.vim.generate-syntax" run - -...or run it from the command line: - - factor -run=editors.vim.generate-syntax diff --git a/misc/vim/README.md b/misc/vim/README.md new file mode 100644 index 0000000000..e9c1a28b56 --- /dev/null +++ b/misc/vim/README.md @@ -0,0 +1,81 @@ +Vim support for Factor +====================== + +This directory contains various support files that make editing Factor code +more pleasant in Vim. + +## Installation + +The file-layout exactly matches the Vim runtime +structure, so you can install them by copying the contents of this directory +into `~/.vim/` or the equivalent path on other platforms (Open Vim and type +`:help 'runtimepath'` for details). + +## File organization + +The current set of files is as follows: + +* ftdetect/factor.vim - Teach Vim when to load Factor support files. +* ftplugin/factor_settings.vim - Teach Vim to follow the Factor Coding Style guidelines. +* plugin/factor.vim - Teach Vim some commands for navigating Factor source code. See below. +* syntax/factor.vim - Syntax highlighting for Factor code. + +## Commands + +The `plugin/factor.vim` file implements the following commands for navigating Factor source: + +### :FactorVocab factor.vocab.name + +Opens the source file implementing the `factor.vocab.name` vocabulary. + +### :NewFactorVocab factor.vocab.name + +Creates a new factor vocabulary under the working vocabulary root. + +### :FactorVocabImpl + +Opens the main implementation file for the current vocabulary +(name.factor). The keyboard shortcut `<Leader>fi` is bound to this command. + +### :FactorVocabDocs + +Opens the documentation file for the current vocabulary +(name-docs.factor). The keyboard shortcut `<Leader>fd` is bound to this command. + +### :FactorVocabTests + +Opens the unit test file for the current vocabulary +(name-tests.factor). The keyboard shortcut `<Leader>ft` is bound to this command. + +## Configuration + +In order for the `:FactorVocab` command to work, you'll need to set some variables in your vimrc file. + +### g:FactorRoot + +This variable should be set to the root of your Factor +installation. The default value is `~/factor`. + +### g:FactorVocabRoots + +This variable should be set to a list of Factor vocabulary roots. +The paths may be either relative to g:FactorRoot or absolute paths. +The default value is `["core", "basis", "extra", "work"]`. + +### g:FactorNewVocabRoot + +This variable should be set to the vocabulary root in which +vocabularies created with NewFactorVocab should be created. +The default value is `work`. + +## Note + +The syntax-highlighting file is automatically generated to include the +names of all the vocabularies Factor knows about. To regenerate it manually, +run the following code in the listener: + + "editors.vim.generate-syntax" run + +...or run it from the command line: + + factor -run=editors.vim.generate-syntax From 900990bec8b0c4990a559621c2c25b903ed33ce8 Mon Sep 17 00:00:00 2001 From: Keita Haga <keitahaga@mail.com> Date: Thu, 24 Mar 2011 09:25:16 +0900 Subject: [PATCH 6/9] misc/vim/README.md: minor tweaks --- misc/vim/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/vim/README.md b/misc/vim/README.md index e9c1a28b56..e75d02ab8c 100644 --- a/misc/vim/README.md +++ b/misc/vim/README.md @@ -22,7 +22,7 @@ The current set of files is as follows: ## Commands -The `plugin/factor.vim` file implements the following commands for navigating Factor source: +The `plugin/factor.vim` file implements the following commands for navigating Factor source. ### :FactorVocab factor.vocab.name @@ -76,6 +76,6 @@ run the following code in the listener: "editors.vim.generate-syntax" run -...or run it from the command line: +or run it from the command line: factor -run=editors.vim.generate-syntax From 69ec12c2dc194110175c5ed8aadfcb9e87754cfb Mon Sep 17 00:00:00 2001 From: John Benediktsson <mrjbq7@gmail.com> Date: Fri, 25 Mar 2011 12:20:51 -0700 Subject: [PATCH 7/9] io: improve signature of each-block and each-line. --- core/io/io.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/io/io.factor b/core/io/io.factor index ea37c13dd7..0821cfff78 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -90,10 +90,10 @@ SYMBOL: error-stream PRIVATE> -: each-stream-line ( stream quot -- ) +: each-stream-line ( stream quot: ( ... line -- ... ) -- ) swap [ stream-readln ] curry each-morsel ; inline -: each-line ( quot -- ) +: each-line ( quot: ( ... line -- ... ) -- ) input-stream get swap each-stream-line ; inline : stream-lines ( stream -- seq ) @@ -111,10 +111,10 @@ PRIVATE> : contents ( -- seq ) input-stream get stream-contents ; inline -: each-stream-block ( stream quot: ( block -- ) -- ) +: each-stream-block ( stream quot: ( ... block -- ... ) -- ) swap [ 8192 swap stream-read-partial ] curry each-morsel ; inline -: each-block ( quot: ( block -- ) -- ) +: each-block ( quot: ( ... block -- ... ) -- ) input-stream get swap each-stream-block ; inline : stream-copy ( in out -- ) From 3523d24785b069e8a97b8bebef62cc478f5dd0a6 Mon Sep 17 00:00:00 2001 From: John Benediktsson <mrjbq7@gmail.com> Date: Fri, 25 Mar 2011 13:58:16 -0700 Subject: [PATCH 8/9] io: implement "stream-contents" in terms of "each-stream-block". --- core/io/io.factor | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/io/io.factor b/core/io/io.factor index 0821cfff78..bd1bf27985 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -102,21 +102,21 @@ PRIVATE> : lines ( -- seq ) input-stream get stream-lines ; inline +: each-stream-block ( stream quot: ( ... block -- ... ) -- ) + swap 65536 swap [ stream-read-partial ] 2curry each-morsel ; inline + +: each-block ( quot: ( ... block -- ... ) -- ) + input-stream get swap each-stream-block ; inline + : stream-contents ( stream -- seq ) [ - [ [ 65536 swap stream-read-partial dup ] curry [ ] produce nip ] + [ [ ] collector [ each-stream-block ] dip { } like ] [ stream-element-exemplar concat-as ] bi ] with-disposal ; : contents ( -- seq ) input-stream get stream-contents ; inline -: each-stream-block ( stream quot: ( ... block -- ... ) -- ) - swap [ 8192 swap stream-read-partial ] curry each-morsel ; inline - -: each-block ( quot: ( ... block -- ... ) -- ) - input-stream get swap each-stream-block ; inline - : stream-copy ( in out -- ) [ [ [ write ] each-block ] with-output-stream ] curry with-input-stream ; From f9ccaf37ec7b286fb5cfd2196c45a299204bdf27 Mon Sep 17 00:00:00 2001 From: John Benediktsson <mrjbq7@gmail.com> Date: Fri, 25 Mar 2011 18:30:52 -0700 Subject: [PATCH 9/9] io: improve stack effects. --- core/io/io.factor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/io/io.factor b/core/io/io.factor index bd1bf27985..a4b93f3f82 100644 --- a/core/io/io.factor +++ b/core/io/io.factor @@ -90,10 +90,10 @@ SYMBOL: error-stream PRIVATE> -: each-stream-line ( stream quot: ( ... line -- ... ) -- ) +: each-stream-line ( ... stream quot: ( ... line -- ... ) -- ... ) swap [ stream-readln ] curry each-morsel ; inline -: each-line ( quot: ( ... line -- ... ) -- ) +: each-line ( ... quot: ( ... line -- ... ) -- ... ) input-stream get swap each-stream-line ; inline : stream-lines ( stream -- seq ) @@ -102,10 +102,10 @@ PRIVATE> : lines ( -- seq ) input-stream get stream-lines ; inline -: each-stream-block ( stream quot: ( ... block -- ... ) -- ) +: each-stream-block ( ... stream quot: ( ... block -- ... ) -- ... ) swap 65536 swap [ stream-read-partial ] 2curry each-morsel ; inline -: each-block ( quot: ( ... block -- ... ) -- ) +: each-block ( ... quot: ( ... block -- ... ) -- ... ) input-stream get swap each-stream-block ; inline : stream-contents ( stream -- seq )