Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Syntastic Segment #451

Closed
wants to merge 1 commit into from
Closed

Added Syntastic Segment #451

wants to merge 1 commit into from

Conversation

dhruvasagar
Copy link

Add a new segment to the theme/vim/default.json with name 'syntastic_segment' and it will display the SyntasticStatuslineFlag from syntastic.

@ZyX-I
Copy link
Contributor

ZyX-I commented Apr 22, 2013

Merge branch 'feature/syntastic' into develop

You should request to pull feature/syntastic, not develop branch. This way there is no need in merging.

@dhruvasagar
Copy link
Author

I had thought of that after I had already merged. Will keep that in mind in future. I have updated my coded and rebased it to ensure cleaner history.

Can you please review it ?

Another question, for me all tests except test_cpu_load_percent pass. I am not sure why this test fails however. Travis seems to be passing my code so I suppose this PR is good to go.

Should I add tests ?

@ZyX-I
Copy link
Contributor

ZyX-I commented Apr 22, 2013

What is the comma change for? It is not JSON and having trailing commas has advantage of more simple new items addition, deletion and rearranging.

By the way, if your segment output consists of only a contents key you can just return its value (return str(syntastic_flag_func())). It is not required, but is usually more convenient when writing new segments and makes python use less ticks to process function output (see theme.py#L98 for list and line 128 below).

Add a new segment to theme with name 'syntastic_segment' and it will
display the SyntasticStatuslineFlag from syntastic.

Refactored Syntastic Segment

Checking if function SyntasticStatuslineFlag exists in vim first before
getting it's value.

Refactored further
@dhruvasagar
Copy link
Author

Hope this looks good

@dhruvasagar
Copy link
Author

Not good to be accepted ?

@zhaocai
Copy link

zhaocai commented Apr 26, 2013

I forget to enable syntastic, then I get the error message. I guess you need to check existence before call

vim_funcs['syntasticflag']()
Error detected while processing function Powerline:
line    3:
E700: Unknown function: SyntasticStatuslineFlag
2013-04-26 17:28:49,490:ERROR:vim:syntastic_segment:Exception while computing segment: 'long' object is not callable
Error detected while processing function Powerline:
line    3:
Traceback (most recent call last):
Error detected while processing function Powerline:
line    3:
  File "/Library/Python/2.7/site-packages/Powerline-beta-py2.7.egg/powerline/theme.py", line 89, in get_segments
Error detected while processing function Powerline:
line    3:
    contents = segment['contents_func'](pl=self.pl, segment_info=segment_info, **segment['args'])
Error detected while processing function Powerline:
line    3:
  File "/Library/Python/2.7/site-packages/Powerline-beta-py2.7.egg/powerline/segments/vim.py", line 91, in ret
Error detected while processing function Powerline:
line    3:
    r = func(**kwargs)
Error detected while processing function Powerline:
line    3:
  File "/Library/Python/2.7/site-packages/Powerline-beta-py2.7.egg/powerline/segments/vim.py", line 497, in syntastic_segment
Error detected while processing function Powerline:
line    3:
    return [{'contents': str(vim_funcs['syntasticflag']())}]
Error detected while processing function Powerline:
line    3:
TypeError: 'long' object is not callable

@zhaocai
Copy link

zhaocai commented Apr 26, 2013

something like this can work

@window_cached
def syntastic_segment(pl):
    '''Return the syntastic statusline flag
    '''
    if vim_funcs['syntasticflag']:
        return [{'contents': str(vim_funcs['syntasticflag']())}]
    else:
        return None

@dhruvasagar
Copy link
Author

You might have to pull the latest, I made changes that fixes stuff. I don't have a 'syntasticflag' key for vim_funcs. Have a look at the diffs.

@zhaocai
Copy link

zhaocai commented Apr 27, 2013

I did not notice you stripped the code to the develop branch. thanks

@dhruvasagar
Copy link
Author

Why is this still open ? :(

@Lokaltog
Copy link
Member

Lokaltog commented May 7, 2013

Sorry about the lack of feedback! I'll test and merge this PR along with a couple of others when I have time for it, hopefully this week.

@dhruvasagar
Copy link
Author

Sure, take it easy :)

@derekleverenz
Copy link

+1 for merging this, a syntactic segment would be great.

@kurojishi
Copy link

+1 for me too i really need this

@Lokaltog Lokaltog closed this in 6baf1f8 Aug 20, 2013
Lokaltog added a commit that referenced this pull request Aug 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants