Skip to content

Commit

Permalink
Fixes for nicholasbloom features
Browse files Browse the repository at this point in the history
Some fixes after PR. Testing, documentation, added version message
  • Loading branch information
mangecoeur committed May 6, 2015
1 parent b5f2a1f commit 5b41524
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 13 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Uses the [bibtexparser](https://github.com/sciunto/python-bibtexparser) library

# Configuration

You must specify the location of your bibtex file in preferences.
You must specify the location of your bibtex file or files in preferences. Multiple files can be added as a list.

Optionally you can define the bibtex fields to search in when using Citer: Search, the default citation format, and the list of scopes to limit the operation of the plugin (by default, Citer will only suggest citations within plain text scopes and is disabled in source code).

See below for example configuration
Expand All @@ -19,6 +20,8 @@ See below for example configuration
//REQUIRED:

"bibtex_file_path": "example/path/to/file.bib",
// You can also specify a list
//"bibtex_file_path": ["example/path/to/file.bib", "example/path/to/fileTwo.bib"],

//OPTIONAL:

Expand All @@ -41,6 +44,8 @@ See below for example configuration

**Citer: Show All** - show all the entries in your bibtex in a quick view (you can then search in the title)

**Citer: Insert Title** - show all the entries in your bibtex in a searchable quick view, inserts the title

# Completions

Citer provides autocompletions for your citekeys, these are enabled by default and can be disabled in the config.
Expand Down
29 changes: 17 additions & 12 deletions citer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ def plugin_loaded():
def plugin_unloaded():
pass

class FindReplaceBracketCommand(sublime_plugin.TextCommand):
def run(self, edit):
lstpos = self.view.find_all(r'\]\[')
for i, pos in reversed(list(enumerate(lstpos))):
self.view.replace(edit, pos, r'; ')
for i, pos in reversed(list(enumerate(lstpos2))):
self.view.replace(edit, pos, r']')

def refresh_caches():
global LST_MOD_TIME
Expand All @@ -86,15 +79,15 @@ def refresh_caches():

if LST_MOD_TIME is None or last_modified_time != LST_MOD_TIME:
LST_MOD_TIME = last_modified_time
for ldoc in BIBFILE_PATH:
with open(BIBFILE_PATH, 'r', encoding="utf-8") as bibfile:
bp = BibTexParser(ldoc.read(), customization=convert_to_unicode)
_DOCUMENTS.append(list(bp.get_entry_list()))
for single_path in BIBFILE_PATH:
with open(single_path, 'r', encoding="utf-8") as bibfile:
bp = BibTexParser(bibfile.read(), customization=convert_to_unicode)
_DOCUMENTS += list(bp.get_entry_list())
_MENU = _make_citekey_menu_list(_DOCUMENTS)
_CITEKEYS = [doc.get('id') for doc in _DOCUMENTS]

else:
last_modified_time = os.path.getmtime(BIBFILE_PATH)
last_modified_time = os.path.getmtime(BIBFILE_PATH)

if LST_MOD_TIME is None or last_modified_time != LST_MOD_TIME:
LST_MOD_TIME = last_modified_time
Expand All @@ -105,6 +98,8 @@ def refresh_caches():
_CITEKEYS = [doc.get('id') for doc in _DOCUMENTS]

# Do some fancy build to get a sane list in the UI


def _make_citekey_menu_list(bibdocs):
citekeys = []
for doc in bibdocs:
Expand Down Expand Up @@ -217,6 +212,7 @@ def _paste(self, item):


class CiterGetTitleCommand(sublime_plugin.TextCommand):

"""
"""
current_results_list = []
Expand Down Expand Up @@ -258,3 +254,12 @@ def on_query_completions(self, view, prefix, loc):
return (results, sublime.INHIBIT_WORD_COMPLETIONS)
else:
return results


class CiterCombineCitationsCommand(sublime_plugin.TextCommand):

def run(self, edit):
lstpos = self.view.find_all(r'\]\[')
for i, pos in reversed(list(enumerate(lstpos))):
self.view.replace(edit, pos, r'; ')

4 changes: 4 additions & 0 deletions messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"install": "messages/install.txt",
"0.6.0": "messages/0.6.0.txt"
}
Empty file added messages/0.6.0.txt
Empty file.
46 changes: 46 additions & 0 deletions messages/install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Citations from bibtex for Sublime Text

This Sublime Text 3 plugin provides citation search and Tab-completion for citations stored in a bibtex file. Configure the file path and you are good to go!

The default set up is optimized to work with AcademicMarkdown.

Uses the [bibtexparser](https://github.com/sciunto/python-bibtexparser) library from sciunto.

# Configuration

You must specify the location of your bibtex file in preferences.
Optionally you can define the bibtex fields to search in when using Citer: Search, the default citation format, and the list of scopes to limit the operation of the plugin (by default, Citer will only suggest citations within plain text scopes and is disabled in source code).

See below for example configuration


```js
{
//REQUIRED:

"bibtex_file_path": "example/path/to/file.bib",

//OPTIONAL:

//By default Citer Search looks for your keyword in the
//author, title, year, and Citekey (id) feilds
"search_fields": ["author", "title", "year", "id"] ,
//Default format is @Citekey
"citation_format": "@%s",
//list of scopes. Could be top level "text" or "source", or limit to
// e.g "text.html.markdown"
"completions_scopes": ["text"],
"enable_completions": true
}
```


# Commands

**Citer: Search** - enter a search term. All results where the term is found in the author, title, citekey, or year fields will be shown (the searched fields are configurable)

**Citer: Show All** - show all the entries in your bibtex in a quick view (you can then search in the title)

# Completions

Citer provides autocompletions for your citekeys, these are enabled by default and can be disabled in the config.

0 comments on commit 5b41524

Please sign in to comment.