aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--snap/snapcraft.yaml41
-rw-r--r--src/nvim/path.c8
-rw-r--r--test/functional/eval/fnamemodify_spec.lua39
-rw-r--r--test/functional/legacy/fnamemodify_spec.lua22
4 files changed, 100 insertions, 10 deletions
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
new file mode 100644
index 0000000000..81ffb9adf3
--- /dev/null
+++ b/snap/snapcraft.yaml
@@ -0,0 +1,41 @@
+name: neovim
+version: git
+summary: Vim-fork focused on extensibility and agility.
+description: |
+ Neovim is a project that seeks to aggressively refactor Vim in order to:
+
+ Simplify maintenance and encourage contributions
+ Split the work between multiple developers
+ Enable the implementation of new/modern user interfaces without any modifications to the core source
+ Improve extensibility with a new plugin architecture
+ For lots more details, see the wiki!
+confinement: classic
+
+apps:
+ neovim:
+ command: usr/local/bin/nvim
+ plugs: [network, network-bind, x11]
+ environment:
+ HOME: /home/$USER
+ VIM: $SNAP/usr/local/share/nvim/runtime
+
+parts:
+ neovim:
+ source: .
+ plugin: make
+ make-parameters:
+ - CMAKE_BUILD_TYPE=Release
+ build-packages:
+ - ninja-build
+ - libtool
+ - libtool-bin
+ - autoconf
+ - automake
+ - cmake
+ - g++
+ - pkg-config
+ - unzip
+ snap:
+ - usr/local/bin
+ - usr/local/share/nvim
+ - -usr/local/share/man
diff --git a/src/nvim/path.c b/src/nvim/path.c
index 09cede8805..21ac064c30 100644
--- a/src/nvim/path.c
+++ b/src/nvim/path.c
@@ -2202,7 +2202,13 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf,
// expand it if forced or not an absolute path
if (force || !path_is_absolute_path(fname)) {
- if ((p = vim_strrchr(fname, PATHSEP)) != NULL) {
+ p = vim_strrchr(fname, '/');
+#ifdef WIN32
+ if (p == NULL) {
+ p = vim_strrchr(fname, '\\');
+ }
+#endif
+ if (p != NULL) {
// relative to root
if (p == fname) {
// only one path component
diff --git a/test/functional/eval/fnamemodify_spec.lua b/test/functional/eval/fnamemodify_spec.lua
new file mode 100644
index 0000000000..fe6b50a544
--- /dev/null
+++ b/test/functional/eval/fnamemodify_spec.lua
@@ -0,0 +1,39 @@
+local helpers = require('test.functional.helpers')(after_each)
+local clear = helpers.clear
+local eq = helpers.eq
+local iswin = helpers.iswin
+local fnamemodify = helpers.funcs.fnamemodify
+local command = helpers.command
+local write_file = helpers.write_file
+
+describe('fnamemodify()', function()
+ setup(function()
+ write_file('Xtest-fnamemodify.txt', [[foobar]])
+ end)
+
+ before_each(clear)
+
+ teardown(function()
+ os.remove('Xtest-fnamemodify.txt')
+ end)
+
+ it('works', function()
+ local root = helpers.pathroot()
+ eq(root, fnamemodify([[/]], ':p:h'))
+ eq(root, fnamemodify([[/]], ':p'))
+ if iswin() then
+ eq(root, fnamemodify([[\]], ':p:h'))
+ eq(root, fnamemodify([[\]], ':p'))
+ command('set shellslash')
+ root = string.sub(root, 1, -2)..'/'
+ eq(root, fnamemodify([[\]], ':p:h'))
+ eq(root, fnamemodify([[\]], ':p'))
+ eq(root, fnamemodify([[/]], ':p:h'))
+ eq(root, fnamemodify([[/]], ':p'))
+ end
+ end)
+
+ it(':8 works', function()
+ eq('Xtest-fnamemodify.txt', fnamemodify([[Xtest-fnamemodify.txt]], ':8'))
+ end)
+end)
diff --git a/test/functional/legacy/fnamemodify_spec.lua b/test/functional/legacy/fnamemodify_spec.lua
index d8ecbfe058..7e859bf0cf 100644
--- a/test/functional/legacy/fnamemodify_spec.lua
+++ b/test/functional/legacy/fnamemodify_spec.lua
@@ -4,8 +4,6 @@ local helpers = require('test.functional.helpers')(after_each)
local clear, source = helpers.clear, helpers.source
local call, eq, nvim = helpers.call, helpers.eq, helpers.meths
-if helpers.pending_win32(pending) then return end
-
local function expected_empty()
eq({}, nvim.get_vvar('errors'))
end
@@ -16,17 +14,21 @@ describe('filename modifiers', function()
source([=[
func Test_fnamemodify()
- let tmpdir = resolve('/tmp')
+ if has('win32')
+ set shellslash
+ else
+ set shell=sh
+ endif
+ let tmpdir = resolve($TMPDIR)
+ call assert_true(isdirectory(tmpdir))
execute 'cd '. tmpdir
- set shell=sh
- set shellslash
let $HOME=fnamemodify('.', ':p:h:h:h')
call assert_equal('/', fnamemodify('.', ':p')[-1:])
- call assert_equal('p', fnamemodify('.', ':p:h')[-1:])
+ call assert_equal(tmpdir[strchars(tmpdir) - 1], fnamemodify('.', ':p:h')[-1:])
call assert_equal('t', fnamemodify('test.out', ':p')[-1:])
call assert_equal('test.out', fnamemodify('test.out', ':.'))
call assert_equal('../testdir/a', fnamemodify('../testdir/a', ':.'))
- call assert_equal('test.out', fnamemodify('test.out', ':~'))
+ call assert_equal(fnamemodify(tmpdir, ':~').'/test.out', fnamemodify('test.out', ':~'))
call assert_equal('../testdir/a', fnamemodify('../testdir/a', ':~'))
call assert_equal('a', fnamemodify('../testdir/a', ':t'))
call assert_equal('', fnamemodify('.', ':p:t'))
@@ -53,8 +55,10 @@ describe('filename modifiers', function()
quit
call assert_equal("'abc\ndef'", fnamemodify("abc\ndef", ':S'))
- set shell=tcsh
- call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
+ if executable('tcsh')
+ set shell=tcsh
+ call assert_equal("'abc\\\ndef'", fnamemodify("abc\ndef", ':S'))
+ endif
endfunc
func Test_expand()