I would like more control and customisation regarding where Fantomas inserts or remove a line break in the code that's formatted by Fantomas. For instance, the following function is formatted in one line but I would prefer having a line break.
module Xxx =
// Actual
let private emptyOrTrimmed (code: string) = if code = null then "" else code.Trim()
// Expected
let private emptyOrTrimmed (code: string) =
if code = null then "" else code.Trim()
How is it possible, preferably without touching the .editorconfig file (given below) ?
Can we add some comment in the code to disable one rule like it exists for eslint ?
// .editorconfig file
root = true
[*]
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
[*.fs]
end_of_line = lf
max_line_length = 210
fsharp_semicolon_at_end_of_line = false
fsharp_space_before_parameter = true
fsharp_space_before_lowercase_invocation = true
fsharp_space_before_uppercase_invocation = false
fsharp_space_before_class_constructor = false
fsharp_space_before_member = false
fsharp_space_before_colon = false
fsharp_space_after_comma = true
fsharp_space_before_semicolon = false
fsharp_space_after_semicolon = true
fsharp_indent_on_try_with = false
fsharp_space_around_delimiter = true
fsharp_max_if_then_else_short_width = 40
fsharp_max_infix_operator_expression = 50
fsharp_max_newline_infix_operator_expression_number_of_items = 1
fsharp_multiline_infix_multiline_formatter = character_width
fsharp_max_record_width = 40
fsharp_max_record_number_of_items = 1
fsharp_record_multiline_formatter = character_width
fsharp_max_array_or_list_width = 40
fsharp_max_array_or_list_number_of_items = 1
fsharp_array_or_list_multiline_formatter = character_width
fsharp_max_value_binding_width = 40
fsharp_max_function_binding_width = 40
fsharp_max_dot_get_expression_width = 50
fsharp_multiline_block_brackets_on_same_column = false
fsharp_newline_between_type_definition_and_members = false
fsharp_keep_if_then_in_same_line = true
fsharp_max_elmish_width = 10
fsharp_single_argument_web_mode = false
fsharp_align_function_signature_to_indentation = false
fsharp_alternative_long_member_definitions = true
fsharp_disable_elmish_syntax = false
fsharp_strict_mode = false
Just change this setting to assign it to zero:
fsharp_max_function_binding_width=0
Currently, I've managed to "force a line break" where I want, just by putting a comment in the code. In order to be explicit, the comment is // force-line-break, which looks like a "configuration comment" (e.g. for ESLint) but the comment can be anything.
But I still have no way to do the opposite: forcing no line break, which is occurring very often with record object.
Note: for me the most annoying thing with this code formatting is to have several blocks of code doing something similar but not formatted the same way regarding line breaks, which is breaking the symmetry and is penalizing the code scanning (meaning fast reading, where visual similarities help).
Related
I am extremely new to Neovim and I am close to being done with configuring, but I can not seem to figure out how to fix braces indentation.
Here's the issue
What I want
function() {
print('Hello, world!')
}
What happens
function() {
print('Hello, world!')
}
Here is my settings.lua file
local set = vim.opt
set.expandtab = true
set.smarttab = true
set.shiftwidth = 4
set.tabstop = 4
set.hlsearch = true
set.incsearch = true
set.ignorecase = true
set.smartcase = true
set.splitbelow = true
set.splitright = true
set.wrap = true
set.scrolloff = 5
set.fileencoding = 'utf-8'
set.termguicolors = true
set.relativenumber = true
set.cursorline = true
set.hidden = true
Incase you're wondering, I'm using 'windwp/nvim-autopairs' to autopair the braces, brackets, etc. if that has anything to do with it.
I'm try to create new conversion action that the value in UI will be "Use different values for each conversion"
I'm using add_conversion_action.py from example.
In the value_settings I set:
value_settings.default_value = 0.0
value_settings.always_use_default_value = True
But in the UI I got "Don't use a value for this conversion action (not recommended)"
I try to look for answer on developers.google but all looks fine.
Thanks!
The code from example:
# [START add_conversion_action]
def main(client, customer_id):
conversion_action_service = client.get_service("ConversionActionService")
# Create the operation.
conversion_action_operation = client.get_type("ConversionActionOperation")
# Create conversion action.
conversion_action = conversion_action_operation.create
conversion_action.name = f"Earth to Mars Cruises Conversion {uuid.uuid4()}"
conversion_action.type_ = (
client.enums.ConversionActionTypeEnum.UPLOAD_CLICKS
)
conversion_action.category = (
client.enums.ConversionActionCategoryEnum.DEFAULT
)
conversion_action.status = client.enums.ConversionActionStatusEnum.ENABLED
conversion_action.view_through_lookback_window_days = 15
# Create a value settings object.
value_settings = conversion_action.value_settings
value_settings.default_value = 0.0
value_settings.always_use_default_value = True
# Add the conversion action.
conversion_action_response = (
conversion_action_service.mutate_conversion_actions(
customer_id=customer_id,
operations=[conversion_action_operation],
)
)
print(
"Created conversion action "
f'"{conversion_action_response.results[0].resource_name}".'
)
# [END add_conversion_action]
Because you used
value_settings.default_value = 0.0
value_settings.always_use_default_value = True
To set "Use different values for each conversion", value_settings.always_use_default_value must be False.
value_settings.always_use_default_value = False
I've tried using joypad.set(Inputs), but that doesn't seem to do anything. Also joypad.write(Inputs) doesn't even work. I'm stuck in a corner, and I don't know what to do.
This example works for when emulating a GBA. It will make the emulator press right every frame
input = {}
input['A'] = false
input['B'] = false
input['Down'] = false
input['L'] = false
input['Left'] = false
input['Power'] = false
input['R'] = false
input['Right'] = true
input['Select'] = false
input['Start'] = false
input['Up'] = false
while true do
joypad.set(input)
emu.frameadvance()
end
depending what you emulating this also might be useful
input['P1 A'] = false
I'm trying to get a configuration for UncrustifyX that will work with Swift using the Allman Style. I'm using BBUncrustifyPlugin in Xcode. Here's what I have so far:
# indent using tabs
input_tab_size = 8
output_tab_size = 4
indent_columns = output_tab_size
indent_with_tabs = 1
# indent case
indent_switch_case = indent_columns
indent_case_brace = 0
# indent class body
indent_class = True
# newlines
nl_after_semicolon = true
# spaces
# add in general
sp_before_sparen = add
# but remove for
sp_version_paren = remove
sp_catch_paren = remove
sp_scope_paren = remove
sp_func_call_user_paren = remove
# Allman style for curly braces
nl_assign_brace = add
nl_enum_brace = add
nl_union_brace = add
nl_struct_brace = add
nl_class_brace = add
nl_do_brace = add
nl_if_brace = add
nl_for_brace = add
nl_else_brace = add
nl_while_brace = add
nl_switch_brace = add
nl_fcall_brace = add
nl_fdef_brace = add
nl_brace_else = add
nl_brace_while = remove
nl_case_colon_brace = add
nl_after_brace_open = true
# one liners
nl_func_leave_one_liners = true
nl_enum_leave_one_liners = true
nl_create_if_one_liner = true
nl_create_for_one_liner = true
nl_create_while_one_liner = true
It gets most of the braces right, but pulls apart exclamation marks and question marks and has some other problems. I'm not sure what else I can do to make it work right.
I made a gist here:
First I have to say: I can't help you with the configuration of uncrustify.
But perhaps I can offer you another solution: You should have a look at the open source command line tool swiftformat. Among others it supports the allman- aka east-coast- style too.
https://github.com/nicklockwood/SwiftFormat
To clarify, because it was hard to explain in the title.
-- file that contains this code is > "player.lua"
local ply = FindMetaTable("Player")
ply.LastDamageType = "N/A"
this code sets a new variable to all player entities. The variable is just a string of the last entity that did damage to the player. That is made possible by the following code:
-- file that contains this code is > "init.lua"
AddCSLuaFile("shared.lua")
AddCSLuaFile("cl_init.lua")
include("shared.lua")
include("player.lua")
-->
--> OTHER METHODS THAT I DIDN'T INCLUDE
-->
function GM:PlayerShouldTakeDamage(ply, attacker)
ply.LastDamageType=tostring(attacker)
return true
end
My point of doing all this is because I want to have a hud element that will display this string so the client can see what was the last thing that dealt damage to him.
The problem is that, the variable is coming up as nil on the client side file "cl_init", yet if I printed the table that contained all the data that was in the player through the client AND through the server side. both tables were the same excluding the variable I made "LastDamageType"
-- file that contains this code is > "cl_init.lua"
include("shared.lua")
surface.CreateFont("dayz_font",{font="Arial",size=24,weight=400})
function GM:HUDPaint()
local ply = LocalPlayer()
draw.SimpleText("you are "..ply:Nick(),"dayz_font", 150,10,Color(255,120,50),TEXT_ALIGN_CENTER)//TargetID
surface.SetFont("TargetID")
surface.SetTextColor(Color(30,70,130))
surface.SetTextPos(surface.ScreenWidth()-200 ,20)
surface.DrawText("You have ")
surface.SetTextColor(Color(200,90,30))
surface.DrawText(ply:Health())
surface.SetTextColor(Color(30,70,130))
surface.DrawText(" health")
surface.SetTextPos(surface.ScreenWidth()-200 ,35)
surface.DrawText(""..tostring(Entity(1):GetTable().LastDamageType))
-- FOR DEBUGGING PURPOSES, I'M USING "Entity(1)" TO GET MY PLAYER
-- I KNOW THAT "LocalPlayer()" PROBABLY ALSO EQUATES TO THE SAME THING
-- AS WHAT "Entity(1)" IS AT THIS MOMENT BECAUSE I'M TESTING THIS IN SINGLEPLAYER.
end
So it seems that the player data on the client side and the server side are not the SAME thing and that they have to be synchronized or something like that... Or did I miss something important that kept them synchronized?
//////////////////////////////////////////////////
ADDITIONAL INFORMATION
//////////////////////////////////////////////////
These are printed lists of all the variables of my player entity when I did
PrintTable(Entity(1):GetTable())
on both the client side and server side. The first list is on the server and the second is on the client. I will separate them with ==========================
I know you don't probably want to look through the list to just to Ctrl+F and type in "LastDamageType" to highlight it.
/////////////////////////////////////////
SERVER SIDE
CWAttachments:
am_flechetterounds = true
am_magnum = true
am_matchgrade = true
am_slugrounds = true
bg_ak74_rpkbarrel = true
bg_ak74_ubarrel = true
bg_ak74foldablestock = true
bg_ak74heavystock = true
bg_ak74rpkmag = true
bg_ar1560rndmag = true
bg_ar15heavystock = true
bg_ar15sturdystock = true
bg_bipod = true
bg_deagle_compensator = true
bg_deagle_extendedbarrel = true
bg_foldsight = true
bg_longbarrel = true
bg_longbarrelmr96 = true
bg_longris = true
bg_magpulhandguard = true
bg_mp530rndmag = true
bg_mp5_kbarrel = true
bg_mp5_sdbarrel = true
bg_nostock = true
bg_regularbarrel = true
bg_retractablestock = true
bg_ris = true
bg_sg1scope = true
md_acog = true
md_aimpoint = true
md_anpeq15 = true
md_cobram2 = true
md_eotech = true
md_foregrip = true
md_kobra = true
md_m203 = true
md_microt1 = true
md_pbs1 = true
md_pso1 = true
md_saker = true
md_tundra9mm = true
CalcIdeal = 990
CalcSeqOverride = -1
DTVar = function: 0x1ca93680
EditValue = function: 0x2ac6c878
GetEditingData = function: 0x18501238
GetNetworkKeyValue = function: 0x1caf7ec0
GetNetworkVars = function: 0x1caf9640
LastDamageType = Entity [0][worldspawn]
LastPlayerTrace = 859.94995117188
LastSpawnpoint = Entity [61][info_player_start]
NetworkVar = function: 0x2375b100
NetworkVarElement = function: 0x23785a08
NetworkVarNotify = function: 0x1844e3c8
PlayerTrace:
Entity = Entity [0][worldspawn]
Fraction = 0.49089023470879
FractionLeftSolid = 0
Hit = true
HitBox = 0
HitGroup = 0
HitNoDraw = false
HitNonWorld = false
HitNormal = -1.000000 0.000000 0.000000
HitPos = 15359.968750 950.995850 -12563.697266
HitSky = true
HitTexture = TOOLS/TOOLSSKYBOX
HitWorld = true
MatType = 88
Normal = 0.998662 0.047185 -0.021163
PhysicsBone = 0
StartPos = -704.000000 192.000000 -12223.280273
StartSolid = false
SurfaceProps = 77
RestoreNetworkVars = function: 0x184b21a8
SCarMouseMoveX = 0
SCarMouseMoveY = 0
SetNetworkKeyValue = function: 0x1838a3f8
SetupEditing = function: 0x0f107ab8
SetupKeyValue = function: 0x1844da70
WT_RagdollRoper_Roping = false
canChat = 864.94995117188
dt:
m_CurrentPlayerClass:
ClassID = 125
Func = function: 0x1ca70b58
Player = Player [1][UbErZ Andrew900460]
m_bFlashlight = true
m_bInSwim = false
m_bWasNoclipping = false
m_bWasOnGround = true
////////////////////////////////////////////////////////////////
CLIENT SIDE
CWAttachments:
am_flechetterounds = true
am_magnum = true
am_matchgrade = true
am_slugrounds = true
bg_ak74_rpkbarrel = true
bg_ak74_ubarrel = true
bg_ak74foldablestock = true
bg_ak74heavystock = true
bg_ak74rpkmag = true
bg_ar1560rndmag = true
bg_ar15heavystock = true
bg_ar15sturdystock = true
bg_bipod = true
bg_deagle_compensator = true
bg_deagle_extendedbarrel = true
bg_foldsight = true
bg_longbarrel = true
bg_longbarrelmr96 = true
bg_longris = true
bg_magpulhandguard = true
bg_mp530rndmag = true
bg_mp5_kbarrel = true
bg_mp5_sdbarrel = true
bg_nostock = true
bg_regularbarrel = true
bg_retractablestock = true
bg_ris = true
bg_sg1scope = true
md_acog = true
md_aimpoint = true
md_anpeq15 = true
md_cobram2 = true
md_eotech = true
md_foregrip = true
md_kobra = true
md_m203 = true
md_microt1 = true
md_pbs1 = true
md_pso1 = true
md_saker = true
md_tundra9mm = true
CalcIdeal = 990
CalcSeqOverride = -1
ChatGestureWeight = 0
DTVar = function: 0x2be3b410
EditValue = function: 0x3053c750
GetEditingData = function: 0x2bb01b30
GetNetworkKeyValue = function: 0x2bb01d18
GetNetworkVars = function: 0x2bb01d38
LastPlayerTrace = 859.96203613281
NetworkVar = function: 0x2bb01c98
NetworkVarElement = function: 0x2bab5340
NetworkVarNotify = function: 0x2bb01cd8
PlayerTrace:
Entity = Entity [0][worldspawn]
Fraction = 0.49089023470879
FractionLeftSolid = 0
Hit = true
HitBox = 0
HitGroup = 0
HitNoDraw = false
HitNonWorld = false
HitNormal = -1.000000 0.000000 0.000000
HitPos = 15359.968750 950.995850 -12563.697266
HitSky = true
HitTexture = TOOLS/TOOLSSKYBOX
HitWorld = true
MatType = 88
Normal = 0.998662 0.047185 -0.021163
PhysicsBone = 0
StartPos = -704.000000 192.000000 -12223.280273
StartSolid = false
SurfaceProps = 77
RestoreNetworkVars = function: 0x2bb01d58
SetNetworkKeyValue = function: 0x2bb01cf8
SetupEditing = function: 0x2bb01c38
SetupKeyValue = function: 0x2bb01c58
dt:
m_CurrentPlayerClass:
ClassID = 125
Func = function: 0x30283ff8
Player = Player [1][UbErZ Andrew900460]
m_bInSwim = false
m_bWasNoclipping = false
m_bWasOnGround = true
If you wish to have a network shared variable that you can assign to an entity (e.g. a player) you want to use NWVariables. In your situation, since you are saving an entity you want to look at SetNWEntity and GetNWEntity.
Here is how you would implement it in the PlayerShouldTakeDamage hook:
function GM:PlayerShouldTakeDamage(ply, attacker)
ply:SetNWEntity("LastDamageType", attacker)
return true
end