mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-11-05 23:29:27 +01:00
port neovim settings to zig
This commit is contained in:
parent
144370da52
commit
2056b46bf2
4 changed files with 92 additions and 52 deletions
|
@ -4,8 +4,8 @@
|
|||
|
||||
.dependencies = .{
|
||||
.znvim = .{
|
||||
.url = "https://mzte.de/git/LordMZTE/znvim/archive/0f07217feb2ed4e0295242a7b0a157a5f7314602.tar.gz",
|
||||
.hash = "12208ff8bcbed85791fc4a98063967723f351b7898b651a7a3aa75d32dec04bb4a0e",
|
||||
.url = "https://github.com/LordMZTE/znvim/archive/0a55798f24e084faef68e93f180683157a417639.tar.gz",
|
||||
.hash = "1220489beca4ac48804ddfbe85b158a49ee2ceb4bbd98fc03e76f18ec01517f5521a",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,55 +1,5 @@
|
|||
(local cmd vim.cmd)
|
||||
|
||||
(local (wo g opt) (values vim.wo vim.g vim.opt))
|
||||
|
||||
;; Shell
|
||||
(set opt.shell :fish)
|
||||
|
||||
(cmd "syntax on")
|
||||
|
||||
;; Quicker updatetime
|
||||
(set opt.updatetime 1000)
|
||||
|
||||
;; Indentation
|
||||
(set opt.tabstop 4)
|
||||
(set opt.shiftwidth 4)
|
||||
(set opt.expandtab true)
|
||||
|
||||
;; Search
|
||||
(set opt.ignorecase true)
|
||||
(set opt.smartcase true)
|
||||
|
||||
;; Window config
|
||||
(set opt.scrolloff 10)
|
||||
(set opt.number true)
|
||||
(set opt.relativenumber true)
|
||||
(set opt.guifont "Iosevka Nerd Font Mono:h10")
|
||||
(set opt.mouse :a)
|
||||
(set opt.termguicolors true)
|
||||
(set opt.cursorline true)
|
||||
(set opt.cursorcolumn true)
|
||||
|
||||
;; Colorcolumn
|
||||
(set opt.colorcolumn :100)
|
||||
|
||||
;; Folds
|
||||
(set opt.conceallevel 2)
|
||||
|
||||
;; Disable unwanted filetype mappings
|
||||
(set g.no_plugin_maps true)
|
||||
|
||||
;; Disable automatic formatting of Zig code (this is on by default!!!)
|
||||
(set g.zig_fmt_autosave 0)
|
||||
|
||||
;; Other settings
|
||||
(cmd "colorscheme dracula")
|
||||
(cmd "filetype plugin on")
|
||||
|
||||
;; Disable garbage providers
|
||||
(let [garbage [:python :python3 :ruby :perl :node]]
|
||||
(each [_ ga (ipairs garbage)]
|
||||
(tset g (.. :loaded_ ga :_provider) false)))
|
||||
|
||||
;; Compile commands
|
||||
(let [compile-path (. (require :mzte_nv) :compile :compilePath)
|
||||
make-cmd vim.api.nvim_create_user_command]
|
||||
|
|
|
@ -70,6 +70,8 @@ export fn luaopen_mzte_nv(l_: ?*c.lua_State) c_int {
|
|||
}
|
||||
|
||||
fn lOnInit(l: *c.lua_State) !c_int {
|
||||
try @import("options.zig").initOptions();
|
||||
|
||||
c.lua_getglobal(l, "vim"); // 1
|
||||
c.lua_getfield(l, 1, "version");
|
||||
c.lua_call(l, 0, 1); // 2
|
||||
|
|
88
mzte-nv/src/options.zig
Normal file
88
mzte-nv/src/options.zig
Normal file
|
@ -0,0 +1,88 @@
|
|||
const std = @import("std");
|
||||
const znvim = @import("znvim");
|
||||
const nvim = @import("nvim");
|
||||
|
||||
const log = std.log.scoped(.options);
|
||||
|
||||
/// Initializes neovim options.
|
||||
pub fn initOptions() !void {
|
||||
// Shell (defaults to mzteinit since that's my login shell)
|
||||
try setOption("shell", "fish");
|
||||
|
||||
try cmd("syntax on");
|
||||
|
||||
// Quicker updatetime
|
||||
try setOption("updatetime", 1000);
|
||||
|
||||
// Indentation
|
||||
try setOption("tabstop", 4);
|
||||
try setOption("shiftwidth", 4);
|
||||
try setOption("expandtab", true);
|
||||
|
||||
// Search
|
||||
try setOption("ignorecase", true);
|
||||
try setOption("smartcase", true);
|
||||
|
||||
// Window Config
|
||||
try setOption("colorcolumn", "100");
|
||||
try setOption("cursorcolumn", true);
|
||||
try setOption("cursorline", true);
|
||||
try setOption("guifont", "Iosevka Nerd Font Mono:h10");
|
||||
try setOption("mouse", "a");
|
||||
try setOption("number", true);
|
||||
try setOption("relativenumber", true);
|
||||
try setOption("scrolloff", 10);
|
||||
try setOption("termguicolors", true);
|
||||
|
||||
// Folds
|
||||
try setOption("conceallevel", 2);
|
||||
|
||||
// Disable unwanted filetype mappings
|
||||
setVar("g:no_plugin_maps", .{ .bool = true });
|
||||
|
||||
// Disable automatic formatting of Zig code (this is on by default!!!)
|
||||
setVar("g:zig_fmt_autosave", .{ .bool = false });
|
||||
|
||||
// Other settings
|
||||
try cmd("colorscheme dracula");
|
||||
try cmd("filetype plugin on");
|
||||
|
||||
// Disable garbage providers
|
||||
for ([_][]const u8{
|
||||
"python",
|
||||
"python3",
|
||||
"ruby",
|
||||
"perl",
|
||||
"node",
|
||||
}) |garbage| {
|
||||
var buf: [64]u8 = undefined;
|
||||
const opt = try std.fmt.bufPrintZ(&buf, "g:loaded_{s}_provider", .{garbage});
|
||||
setVar(opt, .{ .bool = false });
|
||||
}
|
||||
}
|
||||
|
||||
fn setOption(key: [*:0]const u8, value: anytype) !void {
|
||||
const Val = @TypeOf(value);
|
||||
const ret = switch (@typeInfo(Val)) {
|
||||
.Pointer => nvim.set_option_value(key, 0, value, 0),
|
||||
.Int, .ComptimeInt => nvim.set_option_value(key, value, null, 0),
|
||||
.Bool => nvim.set_option_value(key, @boolToInt(value), null, 0),
|
||||
else => @compileError("Unsupported value type: " ++ @typeName(Val)),
|
||||
};
|
||||
|
||||
if (ret) |err| {
|
||||
log.err("Setting option: {s}", .{err});
|
||||
return error.SetOption;
|
||||
}
|
||||
}
|
||||
|
||||
fn setVar(key: [:0]const u8, value: znvim.TypVal) void {
|
||||
var val = value.toNvim();
|
||||
nvim.set_var(key, key.len, &val, false);
|
||||
}
|
||||
|
||||
fn cmd(cmd_s: [*:0]const u8) !void {
|
||||
if (nvim.do_cmdline_cmd(cmd_s) != nvim.OK) {
|
||||
return error.ExecCmd;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue