void IWpfTextViewCreationListener.TextViewCreated(IWpfTextView textView) { // Create the IVimBuffer after loading the VimRc so that it gets the appropriate // settings IVimBuffer vimBuffer; if (!_vim.TryGetOrCreateVimBufferForHost(textView, out vimBuffer)) { return; } // Visual Studio really puts us in a bind with respect to setting synchronization. It doesn't // have a prescribed time to apply it's own customized settings and in fact differs between // versions (2010 after TextViewCreated and 2012 is before). If we start synchronizing // before Visual Studio settings take affect then they will just overwrite the Vim settings. // // We need to pick a point where VS is done with settings. Then we can start synchronization // and change the settings to what we want them to be. // // In most cases we can just wait until IVsTextViewCreationListener.VsTextViewCreated fires // because that happens after language preferences have taken affect. Unfortunately this won't // fire for ever IWpfTextView. If the IWpfTextView doesn't have any shims it won't fire. So // we post a simple action as a backup mechanism to catch this case. _toSyncSet.Add(vimBuffer); _protectedOperations.BeginInvoke(() => BeginSettingSynchronization(vimBuffer), DispatcherPriority.Loaded); }
IMouseProcessor IMouseProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { if (_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(new VimMouseProcessor(vimBuffer, _keyboardDevice)); } return(null); }
/// <summary> /// Create a fallback key processor for every text view if we don't create a vim buffer /// </summary> /// <param name="wpfTextView"></param> /// <returns></returns> KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { vimBuffer = null; } return(new FallbackKeyProcessor(_vsShell, _dte, _keyUtil, _vimApplicationSettings, wpfTextView, vimBuffer, _scopeData)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { if (_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(GetOrCreate(vimBuffer)); } return(null); }
IWpfTextViewMargin IWpfTextViewMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextViewHost.TextView, out IVimBuffer vimBuffer)) { return(null); } return(CreateCommandMargin(vimBuffer)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(null); } var vimBufferCoordinator = _bufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); return(new VsVimKeyProcessor(_adapter, vimBufferCoordinator, _keyUtil, _reportDesignerUtil)); }
IWpfTextViewMargin IWpfTextViewMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { IVimBuffer vimBuffer; if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextViewHost.TextView, out vimBuffer)) { return(null); } var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(wpfTextViewHost.TextView); return(new CommandMargin(wpfTextViewHost.TextView.VisualElement, vimBuffer, editorFormatMap, _optionsProviderFactories)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { if (!_isVisualAssistInstalled) { return(null); } if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(null); } return(new VisualAssistKeyProcessor(vimBuffer)); }
KeyProcessor IKeyProcessorProvider.GetAssociatedProcessor(IWpfTextView wpfTextView) { // Don't want to invoke the custom processor unless R# is installed on the machine if (!_reSharperUtil.IsInstalled) { return(null); } if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out IVimBuffer vimBuffer)) { return(null); } var vimBufferCoordinator = _vimBufferCoordinatorFactory.GetVimBufferCoordinator(vimBuffer); return(ReSharperKeyUtil.GetOrCreate(vimBufferCoordinator)); }
ITagger <T> IViewTaggerProvider.CreateTagger <T>(ITextView textView, ITextBuffer textBuffer) { if (textView.TextBuffer != textBuffer) { return(null); } if (!_vim.TryGetOrCreateVimBufferForHost(textView, out IVimBuffer vimBuffer)) { return(null); } var vimBufferData = vimBuffer.VimBufferData; Func <IBasicTaggerSource <MarkGlyphTag> > func = () => CreateMarkGlyphTaggerSource(vimBufferData); return(TaggerUtil.CreateBasicTagger( textView.Properties, _key, func.ToFSharpFunc()) as ITagger <T>); }
IWpfTextViewMargin IWpfTextViewMarginProvider.CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { // If the notification has occured then there is nothing else to do. We are done if (_vimApplicationSettings.HaveNotifiedBackspaceSetting) { return(null); } // On the very first IVimBuffer creation the vimrc will be loaded. Go ahead and // attempt to get / create the buffer to ensure the vimrc load has been attempted var wpfTextView = wpfTextViewHost.TextView; IVimBuffer vimBuffer; if (!_vim.TryGetOrCreateVimBufferForHost(wpfTextView, out vimBuffer)) { return(null); } // If there is no vimrc or the load does allow backspace over start then there // is no need to display the warning if (_vim.GlobalSettings.IsBackspaceStart || !_vim.VimRcState.IsLoadSucceeded) { return(null); } var editorFormatMap = _editorFormatMapService.GetEditorFormatMap(wpfTextView); var linkBanner = new LinkBanner(); linkBanner.MarginName = Name; linkBanner.LinkAddress = "https://github.com/jaredpar/VsVim/wiki/FAQ#wiki-backspace"; linkBanner.LinkText = "FAQ"; linkBanner.BannerText = "You may want to change the backspace setting in your vimrc"; linkBanner.Background = editorFormatMap.GetBackgroundBrush(EditorFormatDefinitionNames.Margin, MarginFormatDefinition.DefaultColor); linkBanner.CloseClicked += (sender, e) => { _vimApplicationSettings.HaveNotifiedBackspaceSetting = true; }; return(linkBanner); }