diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..ecf639d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,29 @@ +--- +name: Bug report +about: Create a report to help us improve +labels: bug + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If pertinent, add screenshots to help explain your problem. + +** Context (please complete the following information):** + - Vim version [e.g. 8.0.1157] + - Other plugins installed + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..ef4aa7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,17 @@ +--- +name: Feature request +about: Suggest an idea for this project + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] ; I'd like to be able to [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..b660234 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,59 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: read + +jobs: + test: + name: "test on ${{ matrix.os }} ; ${{ matrix.neovim && 'neovim' || 'vim' }}" + + strategy: + matrix: + # Testing doesn't seem to work on Windows: output log file + # cannot be read... + # os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-latest] + neovim: [false] + # neovim: [false, true] + # TODO: Test different flavours of Vim... + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0 + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Setup Vim + uses: rhysd/action-setup-vim@v1 + # uses: thinca/action-setup-vim@v2 + id: vim + with: + neovim: ${{matrix.neovim }} + configure-args: | + --with-features=huge + + - name: Run tests on Linux + if: runner.os == 'Linux' # headless execution is required on Linux + run: | + bundle list + xvfb-run bundle exec rake ci + - name: Run tests on ${{ matrix.os }} + if: runner.os != 'Linux' + run: | + bundle exec rake ci diff --git a/.gitignore b/.gitignore index 02cdacb..7601deb 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ tags *.sw* *~ *.pyc +tests/lh/*.log +*.lock diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..c5b0ee8 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,35 @@ +# Read the Docs configuration file for Sphinx projects +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the OS, Python version and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.12" + # You can also specify other tool versions: + # nodejs: "20" + # rust: "1.70" + # golang: "1.20" + +# Build documentation in the "doc/" directory with Sphinx +sphinx: + configuration: doc/conf.py + # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs + # builder: "dirhtml" + # Fail on all warnings to avoid broken references + # fail_on_warning: true + +# Optionally build your docs in additional formats such as PDF and ePub +# formats: +# - pdf +# - epub + +# Optional but recommended, declare the Python requirements required +# to build your documentation +# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html +python: + install: + - requirements: doc/requirements.txt diff --git a/VimFlavor b/Flavorfile similarity index 100% rename from VimFlavor rename to Flavorfile diff --git a/Gemfile b/Gemfile index e6bce45..eda7be8 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' -gem 'rspec', '~> 3.9.0' -gem 'vimrunner', '~> 0.3.4' +gem 'rspec', '~> 3.13.0' +gem 'vimrunner', '~> 0.3.5' gem 'rake', '~> 13.0.1' -gem 'vim-flavor', '~> 2.2.2' +gem 'vim-flavor', '~> 4.0.3' diff --git a/README.md b/README.md index 03d292e..4311c02 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,13 @@ -# lh-style [![Last release](https://img.shields.io/github/tag/LucHermitte/lh-style.svg)](https://github.com/LucHermitte/lh-style/releases) [![Build Status](https://secure.travis-ci.org/LucHermitte/lh-style.png?branch=master)](http://travis-ci.org/LucHermitte/lh-style) [![Documentation Status](https://readthedocs.org/projects/lh-style/badge/?version=latest)](http://lh-style.readthedocs.io/en/latest/?badge=latest) [![Project Stats](https://www.openhub.net/p/21020/widgets/project_thin_badge.gif)](https://www.openhub.net/p/21020) +# lh-style [![Last release][Releases-badge]][Releases-url] [![Build Status][gh-action-badge]][gh-action-result] [![Documentation Status][rtd-badge]][rtd-url] [![Project Stats][openhub-badge]][openhub-url] +[Releases-badge]: https://img.shields.io/github/tag/LucHermitte/lh-style.svg +[Releases-url]: https://github.com/LucHermitte/lh-style/tags +[gh-action-badge]: ./../../actions/workflows/tests.yml/badge.svg?branch=master "Test" +[gh-action-result]: ./../../actions/workflows/tests.yml?query=branch%3Amaster +[openhub-badge]: https://www.openhub.net/p/21020/widgets/project_thin_badge.gif +[openhub-url]: https://www.openhub.net/p/21020 +[rtd-badge]: https://readthedocs.org/projects/lh-style/badge/?version=latest +[rtd-url]: http://lh-style.readthedocs.io/en/latest/?badge=latest Discl. This page is currently under heavy reorganization! @@ -69,27 +77,34 @@ Contributions are welcomed. I've yet to write a proper CONTRIBUTING.md guide reg * [editorconfig-vim](https://github.com/editorconfig/editorconfig-vim) (optional). * Install with [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager) any plugin that requires lh-style should be enough. * With [vim-addon-manager](https://github.com/MarcWeber/vim-addon-manager), install lh-style (this is the preferred method because of the [dependencies](http://github.com/LucHermitte/lh-style/blob/master/addon-info.txt)). -```vim -ActivateAddons lh-style -" will also install editorconfig-vim -``` + + ```vim + ActivateAddons lh-style + " will also install editorconfig-vim + ``` + * [vim-flavor](http://github.com/kana/vim-flavor) (which also supports dependencies) -``` -flavor 'LucHermitte/lh-style' -" will also install editorconfig-vim -``` + + ``` + flavor 'LucHermitte/lh-style' + " will also install editorconfig-vim + ``` + * Vundle/NeoBundle: -```vim -Bundle 'LucHermitte/lh-vim-lib' -Bundle 'LucHermitte/lh-style' -" Optional -Bundle 'editorconfig/editorconfig-vim' -``` + + ```vim + Bundle 'LucHermitte/lh-vim-lib' + Bundle 'LucHermitte/lh-style' + " Optional + Bundle 'editorconfig/editorconfig-vim' + ``` + * Clone from the git repositories -``` -git clone git@github.com:LucHermitte/lh-vim-lib.git -git clone git@github.com:LucHermitte/lh-style.git -" Optional -git clone git@github.com:editorconfig/editorconfig-vim' -``` + + ```bash + git clone git@github.com:LucHermitte/lh-vim-lib.git + git clone git@github.com:LucHermitte/lh-style.git + " Optional + git clone git@github.com:editorconfig/editorconfig-vim' + ``` diff --git a/Rakefile b/Rakefile index c73cab2..0508a17 100644 --- a/Rakefile +++ b/Rakefile @@ -15,11 +15,12 @@ end task :test => :spec task :spec do - sh "rspec ~/.vim-flavor/repos/LucHermitte_vim-UT/spec" + # 'spec' is implicitly run as well + # sh 'rspec --require spec_helper' + sh "bundle exec rspec ~/.vim-flavor/repos/LucHermitte_vim-UT/spec/UT_spec_v2.rb" end task :install do - sh 'cat VimFlavor >> tests/VimFlavor' + sh 'cat Flavorfile >> tests/Flavorfile' sh 'cd tests && bundle exec vim-flavor install' end - diff --git a/doc/conf.py b/doc/conf.py index 0ad2a03..625c23a 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -32,23 +32,19 @@ extensions = [ 'sphinx.ext.intersphinx', 'sphinx.ext.todo', - 'sphinx.ext.githubpages' + 'sphinx.ext.githubpages', + "sphinx_rtd_theme", + 'm2r2', ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] -from recommonmark.parser import CommonMarkParser - -source_parsers = { - '.md': CommonMarkParser, -} - # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = ['.rst', '.md'] +source_suffix = ['.rst'] # The encoding of source files. # @@ -59,7 +55,7 @@ # General information about the project. project = u'lh-style' -copyright = u'2011-2017, Luc Hermitte' +copyright = u'2011-2024, Luc Hermitte' author = u'Luc Hermitte' # The version info for the project you're documenting, acts as replacement for @@ -76,7 +72,7 @@ # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = None +language = 'en' # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: @@ -129,7 +125,8 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'default' +# html_theme = 'default' +html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -163,7 +160,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -349,4 +346,6 @@ # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/3/': None} +intersphinx_mapping = { + "Python": ("https://docs.python.org/3/", None), +} diff --git a/doc/install.md b/doc/install.md index 200bf58..107e39b 100644 --- a/doc/install.md +++ b/doc/install.md @@ -28,11 +28,11 @@ Bundle 'editorconfig/editorconfig-vim' ``` - * Clone from the git repositories, and update your [`'runtimepath'`](http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27) + * Clone from the git repositories, and update your ['runtimepath'](http://vimhelp.appspot.com/options.txt.html#%27runtimepath%27) ```bash git clone git@github.com:LucHermitte/lh-vim-lib.git git clone git@github.com:LucHermitte/lh-style.git # Optional - git clone git@github.com:editorconfig/editorconfig-vim' + git clone git@github.com:editorconfig/editorconfig-vim ``` diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..255714d --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,3 @@ +sphinx +sphinx_rtd_theme==2.0.0 +m2r2 diff --git a/mkVba/mk-lh-style.vim b/mkVba/mk-lh-style.vim index 09a4729..a976886 100755 --- a/mkVba/mk-lh-style.vim +++ b/mkVba/mk-lh-style.vim @@ -48,4 +48,4 @@ addon-info.txt plugin/style.vim tests/lh/naming.vim tests/lh/style.vim -VimFlavor +Flavorfile diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ec6e872..3b1ce07 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -15,20 +15,39 @@ def runtime(script) command("runtime #{script_path}") end end -end + module Platform + # For tests use in order of priority: + # 1. gvim -- when available + # 2. vim -- if possible + # nvim is not compatible with vimrunner, let's ignore it now + def best_vim + prefered_vims.find { |vim| suitable?(vim) } or raise NoSuitableVimError + end + private + + def prefered_vims + gvims + %w( vim ) + end + end + +end Vimrunner::RSpec.configure do |config| + # Use a single Vim instance for the test suite. Set to false to use an + # instance per test (slower, but can be easier to manage). config.reuse_server = true vim_plugin_path = File.expand_path('.') vim_flavor_path = ENV['HOME']+'/.vim/flavors' + # Use different vimrc in order to see packages installed by vim-flavor + vimrc = File.expand_path('../support/test.vimrc', __FILE__) + + # Decide how to start a Vim instance. In this block, an instance + # should be spawned and set up with anything project-specific. config.start_vim do - vim = Vimrunner.start_gvim - # vim = Vimrunner.start - # pp vim.echo('&rtp') - + vim = Vimrunner::Server.new(:executable => Vimrunner::Platform.best_vim, :vimrc => vimrc).start vim.add_plugin(vim_flavor_path, 'bootstrap.vim') pp vim.echo('&rtp') vim.prepend_runtimepath(vim_plugin_path+'/after') @@ -58,17 +77,18 @@ def runtime(script) vim.prepend_runtimepath(vim_brackets_path) vim.runtime('plugin/misc_map.vim') # Inoreab vim.runtime('plugin/common_brackets.vim') # Brackets - vim.runtime('plugin/bracketing.base.vim') # !mark! + vim.runtime('plugin/bracketing.base.vim') # !mark!, !jump! vim.command('set enc=utf-8') vim.command('SetMarker <+ +>') - # pp vim.echo('&rtp') + pp vim.echo('"RTP -> " . &rtp') vim.command('set shm=') has_redo = vim.echo('has("patch-7.4.849")') if has_redo != "1" puts "WARNING: this flavor of vim won't permit to support redo" end + # The returned value is the Client available in the tests. vim end end @@ -85,4 +105,3 @@ def write_file(filename, contents) end # vim:set sw=2: - diff --git a/spec/support/test.vimrc b/spec/support/test.vimrc new file mode 100644 index 0000000..f9a8a8f --- /dev/null +++ b/spec/support/test.vimrc @@ -0,0 +1,10 @@ +" Special vimrc to used instead of vimrunner vimrc which disable all plugins +" It should automatically load plugins installed as packages by vim-flavor +set nocompatible + +filetype plugin on +filetype indent on +syntax on + +set noswapfile nobackup +set loadplugins diff --git a/tests/Flavorfile b/tests/Flavorfile new file mode 100644 index 0000000..0191903 --- /dev/null +++ b/tests/Flavorfile @@ -0,0 +1,3 @@ +flavor 'LucHermitte/vim-UT', '>= 2.0.8' +flavor 'LucHermitte/lh-brackets', '>= 3.5.4' +flavor 'editorconfig/editorconfig-vim' diff --git a/tests/VimFlavor b/tests/VimFlavor deleted file mode 100644 index 4e4e77e..0000000 --- a/tests/VimFlavor +++ /dev/null @@ -1,3 +0,0 @@ -flavor 'LucHermitte/vim-UT', '>= 0.4.0' -flavor 'LucHermitte/lh-brackets', '>= 3.1.2' -flavor 'editorconfig/editorconfig-vim' diff --git a/tests/lh/style.vim b/tests/lh/style.vim index 1335aa6..67d9f2c 100644 --- a/tests/lh/style.vim +++ b/tests/lh/style.vim @@ -6,7 +6,7 @@ " " Version: 1.0.0 " Created: 14th Feb 2014 -" Last Update: 09th Mar 2021 +" Last Update: 25th Aug 2024 "------------------------------------------------------------------------ " Description: " Unit tests for lh#style @@ -636,7 +636,7 @@ function! s:Test_use_ibs_kr() " #{{{3 endtry endfunction -function! s:Test_use_ibs_0tbs() " #{{{3 +function! s:Test_use_ibs_otbs() " #{{{3 " int main(int argc, char *argv[]) " { " if (x < 0) { @@ -661,7 +661,7 @@ function! s:Test_use_ibs_0tbs() " #{{{3 try new " same ft set ft=cpp - call lh#style#use({"indent_brace_style": "0TBS"}, {"buffer": 1}) + call lh#style#use({"indent_brace_style": "OTBS"}, {"buffer": 1}) AssertEqual(lh#style#apply('class toto{toto};#').'#', "class toto\n{\ntoto\n};\n##") AssertEqual(lh#style#apply('class toto{toto};').'##', "class toto\n{\ntoto\n};##") AssertEqual(lh#style#apply('int main(){toto;}').'##', "int main()\n{\ntoto;\n}##")