Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #116 from mrjones2014/matjones/115-fix-user-config
Browse files Browse the repository at this point in the history
Fix user config not being applied
  • Loading branch information
mrjones2014 authored Nov 7, 2021
2 parents a2041cc + 5ce7247 commit 14d8d25
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Binary file modified bin/arm/libdash_nvim.so
Binary file not shown.
Binary file modified bin/x86/libdash_nvim.so
Binary file not shown.
28 changes: 14 additions & 14 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
use crate::constants;
use mlua::prelude::{LuaError, LuaFunction, LuaTable, LuaValue};
use mlua::{FromLua, Lua};

use crate::constants;

fn set_config(config: &LuaTable, new_config: &LuaTable, key: &str) {
if new_config.contains_key(key).unwrap() {
let new_value = new_config
.get(key)
.unwrap_or(config.get::<&str, LuaValue>(key).unwrap());
config.set(key, new_value).unwrap();
}
}

pub fn get_config_table(lua: &Lua) -> LuaTable {
let require: LuaFunction = lua.globals().get("require").unwrap();
let module: LuaTable = require.call("libdash_nvim").unwrap();
Expand Down Expand Up @@ -101,9 +91,19 @@ pub fn init_config(lua: &Lua) -> LuaTable {
pub fn setup<'a>(lua: &'a Lua, new_config: LuaTable) -> Result<LuaTable<'a>, LuaError> {
let config_table: LuaTable = get_config_table(lua);

set_config(&config_table, &new_config, "dash_app_path");
set_config(&config_table, &new_config, "debounce");
set_config(&config_table, &new_config, "search_engine");
let dash_app_path: String = new_config
.get("dash_app_path")
.unwrap_or(config_table.get("dash_app_path").unwrap());
let debounce: String = new_config
.get("debounce")
.unwrap_or(config_table.get("debounce").unwrap());
let search_engine: String = new_config
.get("search_engine")
.unwrap_or(config_table.get("search_engine").unwrap());

config_table.set("dash_app_path", dash_app_path).unwrap();
config_table.set("debounce", debounce).unwrap();
config_table.set("search_engine", search_engine).unwrap();

if new_config.contains_key("file_type_keywords").unwrap() {
let keywords_config_value: LuaValue = new_config.get("file_type_keywords").unwrap();
Expand Down

0 comments on commit 14d8d25

Please sign in to comment.