Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext-ihaskell
Commits
91836d01
Commit
91836d01
authored
Jan 26, 2014
by
Andrew Gibiansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added :ext completion (again!), closes #168
parent
258a07d3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
24 deletions
+41
-24
Test.ipynb
notebooks/Test.ipynb
+1
-1
Completion.hs
src/IHaskell/Eval/Completion.hs
+40
-23
No files found.
notebooks/Test.ipynb
View file @
91836d01
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
"collapsed": false,
"collapsed": false,
"input": [
"input": [
"import Control.Monad.Identity\n",
"import Control.Monad.Identity\n",
"
lkajsdflkj
"
"
:
"
],
],
"language": "python",
"language": "python",
"metadata": {},
"metadata": {},
...
...
src/IHaskell/Eval/Completion.hs
View file @
91836d01
...
@@ -52,6 +52,7 @@ data CompletionType
...
@@ -52,6 +52,7 @@ data CompletionType
|
HsFilePath
String
String
|
HsFilePath
String
String
|
FilePath
String
String
|
FilePath
String
String
|
KernelOption
String
|
KernelOption
String
|
Extension
String
deriving
(
Show
,
Eq
)
deriving
(
Show
,
Eq
)
complete
::
String
->
Int
->
Interpreter
(
String
,
[
String
])
complete
::
String
->
Int
->
Interpreter
(
String
,
[
String
])
...
@@ -95,24 +96,33 @@ complete line pos = do
...
@@ -95,24 +96,33 @@ complete line pos = do
return
$
filter
(
prefix
`
isPrefixOf
`)
moduleNames
return
$
filter
(
prefix
`
isPrefixOf
`)
moduleNames
DynFlag
ext
->
do
DynFlag
ext
->
do
-- Possibly leave out the fLangFlags? The
-- -XUndecidableInstances vs. obsolete
-- -fallow-undecidable-instances.
let
extName
(
name
,
_
,
_
)
=
name
let
extName
(
name
,
_
,
_
)
=
name
otherNames
=
[
"-package"
,
"-Wall"
,
"-w"
]
++
concatMap
getSetName
kernelOpts
kernelOptNames
=
concatMap
getSetName
kernelOpts
fNames
=
map
(
"-f"
++
)
(
names
++
nonames
)
otherNames
=
[
"-package"
,
"-Wall"
,
"-w"
]
where
-- possibly leave out the fLangFlags? The
fNames
=
map
extName
fFlags
++
-- -XUndecidableInstances vs. obsolete
map
extName
fWarningFlags
++
-- -fallow-undecidable-instances
map
extName
fLangFlags
names
=
map
extName
fFlags
++
fNoNames
=
map
(
"no"
++
)
fNames
map
extName
fWarningFlags
++
fAllNames
=
map
(
"-f"
++
)
(
fNames
++
fNoNames
)
map
extName
fLangFlags
nonames
=
map
(
"no"
++
)
names
xNames
=
map
extName
xFlags
xNoNames
=
map
(
"No"
++
)
xNames
xNames
=
map
(
"-X"
++
)
(
names
++
nonames
)
xAllNames
=
map
(
"-X"
++
)
(
xNames
++
xNoNames
)
where
names
=
map
extName
xFlags
allNames
=
xAllNames
++
otherNames
++
fAllNames
nonames
=
map
(
"No"
++
)
names
return
$
filter
(
ext
`
isPrefixOf
`)
$
fNames
++
xNames
++
otherNames
return
$
filter
(
ext
`
isPrefixOf
`)
allNames
Extension
ext
->
do
let
extName
(
name
,
_
,
_
)
=
name
xNames
=
map
extName
xFlags
xNoNames
=
map
(
"No"
++
)
xNames
return
$
filter
(
ext
`
isPrefixOf
`)
$
xNames
++
xNoNames
HsFilePath
lineUpToCursor
match
->
completePathWithExtensions
[
".hs"
,
".lhs"
]
lineUpToCursor
HsFilePath
lineUpToCursor
match
->
completePathWithExtensions
[
".hs"
,
".lhs"
]
lineUpToCursor
...
@@ -149,17 +159,18 @@ completionType :: String -- ^ The line on which the completion is bei
...
@@ -149,17 +159,18 @@ completionType :: String -- ^ The line on which the completion is bei
completionType
line
loc
target
completionType
line
loc
target
-- File and directory completions are special
-- File and directory completions are special
|
startswith
":!"
stripped
|
startswith
":!"
stripped
=
case
parseShell
lineUpToCursor
of
=
fileComplete
FilePath
Right
xs
->
FilePath
lineUpToCursor
$
if
endswith
(
last
xs
)
lineUpToCursor
then
(
last
xs
)
else
[]
Left
_
->
Empty
|
startswith
":l"
stripped
|
startswith
":l"
stripped
=
case
parseShell
lineUpToCursor
of
=
fileComplete
HsFilePath
Right
xs
->
HsFilePath
lineUpToCursor
$
if
endswith
(
last
xs
)
lineUpToCursor
then
(
last
xs
)
else
[]
Left
_
->
Empty
-- Complete :set, :opt, and :ext
|
startswith
":s"
stripped
|
startswith
":s"
stripped
=
DynFlag
candidate
=
DynFlag
candidate
|
startswith
":o"
stripped
|
startswith
":o"
stripped
=
KernelOption
candidate
=
KernelOption
candidate
|
startswith
":e"
stripped
=
Extension
candidate
-- Use target for other completions.
-- Use target for other completions.
-- If it's empty, no completion.
-- If it's empty, no completion.
|
null
target
|
null
target
...
@@ -178,6 +189,12 @@ completionType line loc target
...
@@ -178,6 +189,12 @@ completionType line loc target
isModName
=
all
isCapitalized
(
init
target
)
isModName
=
all
isCapitalized
(
init
target
)
isCapitalized
=
isUpper
.
head
isCapitalized
=
isUpper
.
head
lineUpToCursor
=
take
loc
line
lineUpToCursor
=
take
loc
line
fileComplete
filePath
=
case
parseShell
lineUpToCursor
of
Right
xs
->
filePath
lineUpToCursor
$
if
endswith
(
last
xs
)
lineUpToCursor
then
last
xs
else
[]
Left
_
->
Empty
-- | Get the word under a given cursor location.
-- | Get the word under a given cursor location.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment