How to map leader as BackSpace using vim module from lua? - neovim

I know that in vim I can do
let mapleader = "\<BS>"
However, using vim module from lua does not seem to work. I tried options such as
vim.g.mapleader = [[<BS>]]
vim.g.mapleader = [[\<BS>]]
vim.g.mapleader = "\<BS>"
vim.g.mapleader = "<BS>"
but none is good.

vim.g.mapleader = vim.api.nvim_replace_termcodes('<BS>', false, false, true)
Credit to https://neovim.discourse.group/t/vim-g-mapleader-bs-not-working/3220/2

Related

After updating neovim to 0.81 and all plugins to latest release, autocmd to highlight words on cursor hold is not working on certain languages

I have an auto command highlight words on cursor hold and this autocmd gets attached to buffer when the LSP server has the capability of documentFormattingProvider.
After updating neovim to 0.81 and all the plugins and language servers. The behaviour of this autocmd is buggy.
on svelte files, it does not work and actually outputs error: method textDocument/documentHighlight is not supported by any of the servers registered for the current buffer (lsp:svelte)
on python, no highlighting, no errors, but running lua vim.lsp.buf.document_highlight() on cmd line while cursor on repetitive word, it does highlight (lsp:pyright,black)
on go, it is working! (lsp:gopls)
on typescript files, it is working (lsp:tsserver)
on dart it is working (lsp:dartls)
Here is my dotfiles
local function lsp_highlight_document(client)
-- Set autocommands conditional on server_capabilities
if client.server_capabilities.documentFormattingProvider then
vim.api.nvim_exec(
[[
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]],
false
)
end
end
I also tried (also not working):
local function lsp_highlight_document(client)
-- Set autocommands conditional on server_capabilities
if client.server_capabilities.documentFormattingProvider then
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
vim.api.nvim_clear_autocmds({ buffer = bufnr, group = "lsp_document_highlight" })
vim.api.nvim_create_autocmd("CursorHold", {
callback = vim.lsp.buf.document_highlight,
buffer = bufnr,
group = "lsp_document_highlight",
desc = "Document Highlight",
})
vim.api.nvim_create_autocmd("CursorMoved", {
callback = vim.lsp.buf.clear_references,
buffer = bufnr,
group = "lsp_document_highlight",
desc = "Clear All the References",
})
end
end
Both of these functions gets called here
options.on_attach = function(client, bufnr)
if client.name == "tsserver" then
client.server_capabilities.documentFormattingProvider = true
end
if client.name == "sumneko_lua" then
client.server_capabilities.documentFormattingProvider = false
end
lsp_highlight_document(client)
lsp_keymaps(bufnr)
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not status_ok then
return
end
options.capabilities = cmp_nvim_lsp.default_capabilities(capabilities)
return options
Prior to this update, it was working fine in every language. Not sure what is missing.
Here is my config, which works for pyright, pylsp, lua-language-server etc.:
local api = vim.api
local lsp = vim.lsp
if client.server_capabilities.documentHighlightProvider then
vim.cmd([[
hi! link LspReferenceRead Visual
hi! link LspReferenceText Visual
hi! link LspReferenceWrite Visual
]])
local gid = api.nvim_create_augroup("lsp_document_highlight", { clear = true })
api.nvim_create_autocmd("CursorHold" , {
group = gid,
buffer = bufnr,
callback = function ()
lsp.buf.document_highlight()
end
})
api.nvim_create_autocmd("CursorMoved" , {
group = gid,
buffer = bufnr,
callback = function ()
lsp.buf.clear_references()
end
})
end
Works well on nvim 0.8.1. Try it to see if it works. If it does not work, I think there is something wrong with your config, you need to dig deeper to find why.

Why is my Luau code not hiding the GUIs that I tried to hide?

My code is for hiding some GUIs that I don't want to show. (Note that this is Luau, I can't post to DevForums because I am not a member)
This is what I want to hide:
Link here
The code I used was:
local Dialog = false
local Confirm = false
local TalkTo = ""
local ConfirmGUI = script.Parent.Parent.Parent.Parent.ConfirmGUI.ScreenGui -- Avoiding waste of time writing the full directory and having to fail because it's in PlayerGUI
ConfirmGUI.TextButton.Visible = false
ConfirmGUI.TextButton2.Visible = false
ConfirmGUI.TextLabel.Visible = false
ConfirmGUI.TextTitle.Visible = false
The error I keep getting in Developer Console is:
09:04:06.668 ConfirmGUI is not a valid member of PlayerGui "Players.metoplayllol.PlayerGui" - Client - LocalScript:6
09:04:06.668 Stack Begin - Studio
09:04:06.669 Script 'Players.metoplayllol.PlayerGui.DialogGUI.ScreenGui.TextLabel.LocalScript', Line 6 - Studio - LocalScript:6
09:04:06.669 Stack End - Studio
I used a title you can't see because it ruins the fun of the experience.
Just use this code
ConfirmGUI.TextButton.Visible = false
ConfirmGUI.TextButton2.Visible = false
ConfirmGUI.TextLabel.Visible = false
ConfirmGUI.TextTitle.Visible = false
Try using:
script.Parent...Parent:WaitForChild('ConfirmGUI').ScreenGUI, or flip ScreenGUI and ConfurmGUI

Blank windows with documentation examples of Gtk(0.17) (julia 1.1)

I got an issue with Gtk.
My code is compiling with no error, but only the windows with its title is appearing.
So I wondered if I made something wrong and tried some examples of the documentation (see below).
And it didn't worked either.
I updated the packages, rm, and add again, no error.
No error in compiling, nothing.
When I ask if the widgets are visible it is saying yes.
I saw that it could be a configuration problem of gtk but with no more explanation.
Thank you for your help !
using Gtk
ls = GtkListStore(String, Int, Bool, Bool)
push!(ls,("Peter",20,false,true))
push!(ls,("Paul",30,false,true))
push!(ls,("Mary",25,true,true))
insert!(ls, 2, ("Susanne",35,true,true))
rTxt = GtkCellRendererText()
rTog = GtkCellRendererToggle()
c1 = GtkTreeViewColumn("Name", rTxt, Dict([("text",0)]), sort_column_id=0)
c2 = GtkTreeViewColumn("Age", rTxt, Dict([("text",1)]), sort_column_id=1)
c3 = GtkTreeViewColumn("Female", rTog, Dict([("active",2)]), sort_column_id=2)
tmFiltered = GtkTreeModelFilter(ls)
GAccessor.visible_column(tmFiltered,3)
tv = GtkTreeView(GtkTreeModel(tmFiltered))
push!(tv, c1, c2, c3)
selection = GAccessor.selection(tv)
signal_connect(selection, "changed") do widget
if hasselection(selection)
currentIt = selected(selection)
println("Name: ", GtkTreeModel(tmFiltered)[currentIt,1],
" Age: ", GtkTreeModel(tmFiltered)[currentIt,1])
end
end
ent = GtkEntry()
signal_connect(ent, "changed") do widget
searchText = get_gtk_property(ent, :text, String)
for l=1:length(ls)
showMe = true
if length(searchText) > 0
showMe = showMe && occursin(lowercase(searchText), lowercase(ls[l,1]))
end
ls[l,4] = showMe
end
end
vbox = GtkBox(:v)
push!(vbox,ent,tv)
win = GtkWindow(vbox, "List View with Filter")
showall(win)
I tried it, but run as a file, your app closes so fast you do not see it display at all. This is covered in the Gtk.jl docs under "Non REPL Usage" ie running as a file, outside the julia REPL command line. Just replace showall(win) with:
condition = Condition()
endit(w) = notify(condition)
signal_connect(endit, win, :destroy)
showall(win)
wait(condition)
The app will then pass control to the internal Gtk runtime event loop and wait for the app to close. I was able to run your app and see the check boxes fine with this. If you cannot, you might have a problem with your local files.

Outlook form VBScript for controls

I've created an Outlook form with several bound controls. I would like one of the check boxes when checked to make two text areas and their labels visible, then not be visible if the check box is unchecked. The controls that I want to make visible have the initial state of not-visible. I'm stuck on the VBScript syntax. I've been using Sue Mosher's Outlook programming book, but I'm a newby and I'm not getting it. I'd appreciate any help with this. I'm using Outlook 2010 on a Windows 7 machine. Thanks!
Here's my code:
Sub Item_PropertyChange(byVal Name)
Set objInsp = Item.GetInspector
Set objPage = objInsp.ModifiedFormPages("Message")
Set ckWGC = objPage.Controls("ckWGC")
Set lblState = objPage.Controls("lblState")
Set WGCState = objPage.Controls("WGCState")
Set lblCountry = objPage.Controls("lblCountry")
Set WGCCountry = objPage.Controls("WGCCountry")
If ckWGC.Value = True Then
lblState.Visible = True
WGCState.Visible = True
lblCountry.Visible = True
WGCCountry.Visible = True
Else
lblState.Visible = False
WGCState.Visible = False
lblCountry.Visible = False
WGCCountry.Visible = False
End If
End Sub
You would want to handle the CheckBox.Change event to capture when the user has checked or unchecked it.
Private Sub CheckBox1_Change()
End Sub

PHPMailer AltBody is not working

PHPMailer Version 5.2.7
$mailerObject = new PHPMailer;
$mailerObject->CharSet = 'UTF-8';
$mailerObject->IsSMTP();
$mailerObject->Host = 'dsfdf.sdfsdf.com';
$mailerObject->SMTPAuth = TRUE;
$mailerObject->Username = 'dfgdfg';
$mailerObject->Password = 'dfgdfgdfg';
$mailerObject->SMTPSecure = 'tls';
$mailerObject->WordWrap = 60;
$mailerObject->From = 'alex#test.de';
$mailerObject->FromName = 'test.de';
$mailerObject->AltBody = $bodyTextTemp;
$mailerObject->MsgHTML($bodyHtmlTemp);
I am sending an HTML-Mail and an Text-Mail. In Thunderbird in HTML-Mode HTML is correctly shown. In Text-Mode you cant see the Text-Content ($bodyTextTemp), but the HTML-Content ($bodyHtmlTemp) where all HTML-Tags were removed (looks very ugly...).
Looking to the Mail-source, I can see that the AltBody wasnt send.
Why PHPMail dont accept my AltBody?
Because msgHTML overwrites AltBody. If you want to set Body and AltBody yourself, just set them. msgHTML is a convenience function to do several things for you, but you don't need to use it. If you want to use it but also set AltBody, just set it after you call msgHTML.