I'm running nvim 0.9 with config I took from kickstart.nvim, so nvim-lspconfig, mason plus other stuff.
I configured yapf, based on how I understand the LSP docs and the kickstart.nvim, yet it is not respecting custom column_limit, it seems to be stuck to 79 line length. If yapf is actually the one doing the formatting.
Here is the Format command:
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
And config for pylsp (autopep8 switched off like the docs say):
pylsp = {
plugins = {
autopep8 = {
enabled = false
},
yapf = {
enabled = true,
args = '--style={based_on_style: google column_limit: 120}'
},
pylint = {
enabled = true,
maxLineLength = 120
},
}
}
I'm new to Lua, I'm missing something but can't figure it out where or get a nice search hit on it.
Related
I'm using Google Speech-To-Text to recognize via mic in Windows PC device.
My target language is "ja-JP" and I've already coded app that can recognize some japanese sentences. But I sometime got a strange result Like a "2010|ニセンジュー,ニーゼロイチゼロ 年代|ネンダイ".
I confused such result that included "|". Anybody knows how to create a correct result? Please help me.
I created my application, using Windows C# Google Nuget Library, "Google.Cloud.Speech.V1" version 1.2.0. Language is "ja-JP".
Here is my config information.
var recogConfig = new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "ja-JP",
Model = "command_and_search",
ProfanityFilter = false,
};
StreamingConfig = new StreamingRecognitionConfig()
{
Config = recogConfig,
InterimResults = true,
SingleUtterance = true,
};
I expect the output of "transcript" is "2010年代の".
but the actual output is "2010|ニセンジュー,ニーゼロイチゼロ 年代|ネンダイ の|ノ".
StreamingRecognizeResponse result is below.
{[ { "alternatives": [ { "transcript": "2010|ニセンジュー,ニーゼロイチゼロ 年代|ネンダイ の|ノ" } ], "isFinal": true, "resultEndTime": "2.820s" } ]}
I've just started playing with NixOS, and have so far managed to edit /etc/nixos/configuration.nix in my NixOS 18.09 VM to have PHP-FPM and the Caddy webserver enabled.
{ config, pkgs, ... }:
{
imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
users = {
mutableUsers = false;
groups = {
caddy = { };
php-project = { };
};
users = {
hello = {
group = "php-project";
};
};
};
environment.systemPackages = [
pkgs.htop
pkgs.httpie
pkgs.php # for PHP CLI
];
services.caddy = {
enable = true;
email = "david#example.com";
agree = true;
config = ''
(common) {
gzip
header / -Server
header / -X-Powered-By
}
:8080 {
root /var/www/hello
fastcgi / /run/phpfpm/hello.sock php
log syslog
import common
}
'';
};
services.phpfpm = {
phpOptions = ''
date.timezone = "Europe/Berlin"
'';
poolConfigs = {
hello = ''
user = hello
listen = /run/phpfpm/hello.sock
; ...
pm.max_requests = 500
'';
};
};
}
A PHP-processed response is available at at localhost:8080. (Yay!)
To enable Caddy plugins when compiling from source, Go imports are added to caddy's run.go, e.g.:
_ "github.com/mholt/caddy/caddyhttp" // plug in the HTTP server type
// This is where other plugins get plugged in (imported)
_ "github.com/nicolasazrak/caddy-cache" // added to use another plugin
)
How can I set such line insertion to be performed after the source is downloaded and before the build takes place? (If this is a reasonable approach when using Nix?)
The NixOS 18.09 caddy package.
The NixOS 18.09 caddy service.
I believe that when writing a package a builder script (Bash or otherwise) can be assigned, and I'm thinking the line insertion could be done in it. But I'm lost as to how to assign a script to an existing package in this situation (override an attribute/use an overlay?) and where to put the script on the disk.
Status update
I've been doing some reading on customising packages in general and it sounds like overlays might be what I need. However, I don't seem to be able to get my overlay evaluated.
I'm using overriding of the package name as a test as it's simpler than patching code.
Overlay attempt 1
/etc/nixos/configuration.nix:
{ config, pkgs, options, ... }:
{
imports = [ <nixpkgs/nixos/modules/installer/virtualbox-demo.nix> ];
nix.nixPath = options.nix.nixPath.default ++ [
"nixpkgs-overlays=/etc/nixos/overlays-compat/"
];
# ...
}
/etc/nixos/overlays-compat/overlays.nix:
self: super:
with super.lib;
let
# Using the nixos plumbing that's used to evaluate the config...
eval = import <nixpkgs/nixos/lib/eval-config.nix>;
# Evaluate the config,
paths = (eval {modules = [(import <nixos-config>)];})
# then get the `nixpkgs.overlays` option.
.config.nixpkgs.overlays
;
in
foldl' (flip extends) (_: super) paths self
/etc/nixos/overlays-compat/caddy.nix:
self: super:
{
caddy = super.caddy.override {
name = "caddy-override";
};
}
Overlay attempt 2
/etc/nixos/configuration.nix:
nixpkgs.overlays = [ (self: super: {
caddy = super.caddy.override {
name = "caddy-override";
};
} ) ];
error: anonymous function at /nix/store/mr5sfmz6lm5952ch5q6v49563wzylrkx-nixos-18.09.2327.37694c8cc0e/nixos/pkgs/servers/caddy/default.nix:1:1 called with unexpected argument 'name', at /nix/store/mr5sfmz6lm5952ch5q6v49563wzylrkx-nixos-18.09.2327.37694c8cc0e/nixos/lib/customisation.nix:69:12
overrideAttrs
I previously managed to override the package name with this:
{ config, pkgs, options, ... }:
let
caddyOverride = pkgs.caddy.overrideAttrs (oldAttrs: rec {
name = "caddy-override-v${oldAttrs.version}";
});
in {
{
# ...
services.caddy = {
package = caddyOverride;
# ...
}
}
I could see in htop that the caddy binary was in a folder called /nix/store/...-caddy-override-v0.11.0-bin/. But I understand that overriding in this way has been superseded by overlays.
In order to add plugins to Caddy, it seems that the method is to modify the source.
You will need to adapt the Nixpkgs expression for Caddy to make that possible. That can be done outside the Nixpkgs tree, using services.caddy.package = callPackage ./my-caddy.nix {} for example, or by forking the Nixpkgs repository and pointing your NIX_PATH to your clone.
There is an issue for Caddy plugins: https://github.com/NixOS/nixpkgs/issues/14671
PR welcome!
to experiment with upstream changes i want to alter the src= attribute in pkgs.python27Packages.bepasty-server.
reading through https://nixos.org/nixpkgs/manual/#chap-functions there is no example how to do this for pythonPackages!
so i have tried the stuff below, which i found in some xml-code for the documentation. but it doesn't work ... which is the part where i need your help!
packageOverrides
idea
nixpkgs.config.packageOverrides = super: {
python27Packages.bepasty-server = (pkgs.python27Packages.bepasty-server.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/bepasty/bepasty-server";
sha256 = "1ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
};
}));
results in this:
building Nix...
building the system configuration...
error: attribute ‘gunicorn’ missing, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/services/misc/bepasty.nix:5:14
(use ‘--show-trace’ to show detailed location information)
reducing the code
nixpkgs.config.packageOverrides = super: {
python27Packages.bepasty-server = pkgs.python27Packages.bepasty-server;
};
results in:
[root#nixdoc:~/nixpkgs]# nixos-rebuild build
building Nix...
building the system configuration...
error: attribute ‘gunicorn’ missing, at /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs/nixos/modules/services/misc/bepasty.nix:5:14
(use ‘--show-trace’ to show detailed location information)
so it seems this won't work at all, but why?
systemPackages
in contrast, here it seems to be working:
environment.systemPackages = with pkgs; [
(python27Packages.bepasty-server.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/bepasty/bepasty-server";
sha256 = "1ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
};
}))
file
# gcc-wrapper
gdb
gnumake
gnutls
psmisc
# tlspool
wireshark-cli
gnutls
however, i don't need bepasty-server binaries in the interactive environment but instead i need to override pkgs so the bepasty service will use it!
thanks to lassulus!
here is what works now:
nixpkgs.config.packageOverrides = super: {
pythonPackages = super.pythonPackages // { bepasty-server = super.python27Packages.bepasty-server.overrideAttrs (oldAttrs: {
src = pkgs.fetchgit {
url = "https://github.com/bepasty/bepasty-server";
sha256 = "9ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
#sha256 = "5ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
#sha256 = "7ziqshmsf0rjvdhhca55sm0x8jz76fsf2q4rwh4m6lpcf8wr0nps";
rev = "e2516e8cf4f2afb5185337073607eb9e84a61d2d";
};
});
};
};
Hello,
I've created a custom command in Icinga 2 using this plugin:
https://github.com/justintime/nagios-plugins/blob/master/check_mem/check_mem.pl
check_command
object CheckCommand "memory" {
import "plugin-check-command"
command = [ PluginDir + "/check_mem" ]
arguments = {
"-w" = {
required = true
value = "$mem_warning$"
}
"-c" = {
required = true
value = "$mem_critical$"
}
"-u" = {
required = true
value = "$mem_used$"
}
"-C" = "$mem_cache$"
}
vars.mem_used = true
vars.mem_cache = true
vars.mem_warning = 85
vars.mem_critical = 95
}
service
apply Service "Memory" {
import "generic-service"
check_command = "memory"
assign where host.address
}
However the plugin cannot check the memory and gives the following output in Icinga Web 2 interface:
Plugin Output
*** You must define WARN and CRITICAL levels!
\ncheck_mem.pl v1.0 - Nagios Plugin\n\nusage:\n check_mem.pl -\ncheck_mem.pl comes with absolutely NO WARRANTY either implied or explicit\nThis program is licensed under the terms of the\nMIT License (check source code for details)
Could you please help, what is wrong with this check?
This works with your service
object CheckCommand "memory" {
import "plugin-check-command"
command = [ PluginDir + "/check_mem.pl" ]
arguments = {
"-w" = {
value = "$mem_warning$"
}
"-c" = {
value ="$mem_critical$"
}
"-u" = {
set_if = "$mem_used$"
}
"-C" = {
set_if = "$mem_cache$"
}
}
vars.mem_warning = 85
vars.mem_critical = 95
vars.mem_used = true
vars.mem_cache = true
}
Give like this, you command will get values from service at run time.
apply Service "Memory" {
import "generic-service"
check_command = "memory"
vars.mem_used = true
vars.mem_cache = true
vars.mem_warning = 85
vars.mem_critical = 95
assign where host.address
}
This will replaced while execution refering this will help .If you are using NRPE, please update your question with that, answer may differ for that please refer arguments passing icinga to NRPE.
I am using jms to send messages between two apps, here is the code for receiver app
xmlns amq:"http://activemq.apache.org/schema/core"
amq.'broker'(
useJmx: '${grails.jms.useJmx}',
persistent:'${grails.jms.persistent}',
dataDirectory: '${grails.jms.dataDirectory}'){
amq.'transportConnectors'{
amq.'transportConnector'(uri:'${grails.jms.transportConnector}')
}
}
amqConnectionFactory(ActiveMQConnectionFactory) {
brokerURL = '${grails.jms.brokerUrl}'
}
jmsConnectionFactory(SingleConnectionFactory) { bean ->
targetConnectionFactory = ref(amqConnectionFactory)
}
I am able to run the app but getting error like
"Store limit is 102400 mb, whilst the data directory: /my-activemq-data/localhost/KahaDB only has 7438 mb of usable space" in console. I just want to configure the temp memory usage, can anyone help me on this. thanks
Are you using the https://grails.org/plugin/activemq plugin?
If so, I added precisely that functionality to the plugin.
The plugin allows the following configuration options (just put them in your Config.groovy):
grails.activemq.active = (true|false) default to true
grails.activemq.useJms = (true|false) default to false
grails.activemq.startBroker = (true|false) default to true
grails.activemq.brokerId = (string) default to "brokerId"
grails.activemq.brokerName = (string) default to "localhost"
grails.activemq.persistent = (true|false) default to false
grails.activemq.port = (int) default to 61616
grails.activemq.tempUsageLimit = (size in bytes) defaults to 64Mb
grails.activemq.storeUsageLimit = (size in bytes) defaults to 64Mb
If you aren't using the plugin maybe you should :)
For reference, this is the resources.groovy file I use for most projects (which rely on an application server jndi based JMS service for test and production and use activemq for development):
import grails.util.Environment
import org.apache.activemq.ActiveMQConnectionFactory
import org.springframework.jms.connection.SingleConnectionFactory
import org.springframework.jndi.JndiObjectFactoryBean
beans = {
switch(Environment.current) {
case Environment.PRODUCTION:
case Environment.TEST:
jmsConnectionFactory(JndiObjectFactoryBean) {
jndiName = "java:/ConnectionFactory"
}
break
case Environment.DEVELOPMENT:
jmsConnectionFactory(SingleConnectionFactory) {
targetConnectionFactory = { ActiveMQConnectionFactory cf ->
brokerURL = 'vm://localhost'
}
}
break
}
}
I had the same problem as you while using ActiveMQ with the activemq plugin, so I made a pull request adding those configuration options and setting them to a more reasonable default (for development) of 64Mb.
If you use the plugin you just need to add it to your BuildConfig plugins section, and it should work ok without further configuration, just the resources.groovy inside config/spring.
Anyway, the options I described should go into Config.groovy if you need any of them.
Finally, I got solution to my problem. here is the updated resource.groovy
activeMQTempUsage(TempUsage) {
activeMQTempUsage.limit = 1024 * 1024 * 1024
}
activeMQStoreUsage(StoreUsage) {
activeMQStoreUsage.limit = 1024 * 1024 * 1024
}
activeMQSystemUsage(SystemUsage){
activeMQSystemUsage.tempUsage = ref('activeMQTempUsage')
activeMQSystemUsage.storeUsage = ref('activeMQStoreUsage')
}
tcpConnector(TransportConnector,uri:'tcp://localhost:61616') {
}
connectors(ArrayList,[ref('tcpConnector')]){
}
myBrokerService(XBeanBrokerService){bean->
myBrokerService.useJmx = false
myBrokerService.persistent = true
myBrokerService.dataDirectory = 'my-activemq-data'
myBrokerService.systemUsage = ref('activeMQSystemUsage')
myBrokerService.transportConnectors = ref('connectors')
}
amqConnectionFactory(ActiveMQConnectionFactory) {
brokerURL = 'vm://localhost'
}
jmsConnectionFactory(SingleConnectionFactory) { bean ->
targetConnectionFactory = ref(amqConnectionFactory)
}
Using XbeanBrokerService properties we can achieve this, if you we want add more configuration we can add by using properties of XbeanBrokerService as like above.