Skip to content

Commit

Permalink
chore: renaming config macro so rust-analyzer stops breaking imports …
Browse files Browse the repository at this point in the history
…by assuming it is the module name
  • Loading branch information
sminez committed Sep 17, 2024
1 parent b446157 commit 624fd28
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/buffer/minibuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! modifying the current buffer state.
use crate::{
buffer::{Buffer, GapBuffer, TextObject},
config,
config_handle,
editor::Editor,
key::{Arrow, Key},
util::run_command_blocking,
Expand Down Expand Up @@ -76,7 +76,7 @@ impl MiniBuffer {
let mut mb = MiniBuffer::new(
prompt.to_string(),
initial_lines,
config!().minibuffer_lines,
config_handle!().minibuffer_lines,
);
let mut input = String::new();
let mut x = 0;
Expand Down
10 changes: 5 additions & 5 deletions src/buffer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! A [Buffer] represents a single file or in memory text buffer open within the editor.
use crate::{
config,
config::ColorScheme,
config_handle,
dot::{
find::{find_forward_wrapping, Find},
Cur, Dot, FindDelimited, LineRange, Range, TextObject,
Expand Down Expand Up @@ -498,7 +498,7 @@ impl Buffer {
return 0;
}

let tabstop = config!().tabstop;
let tabstop = config_handle!().tabstop;

let mut rx = 0;
for c in self.txt.line(y).chars().take(x) {
Expand All @@ -518,7 +518,7 @@ impl Buffer {

let mut rx = 0;
let mut cx = 0;
let tabstop = config!().tabstop;
let tabstop = config_handle!().tabstop;

for c in self.txt.line(y).chars() {
if c == '\n' {
Expand Down Expand Up @@ -563,7 +563,7 @@ impl Buffer {
dot_range: Option<(usize, usize)>,
) -> (String, Option<(usize, usize)>) {
let max_chars = screen_cols - lpad;
let tabstop = config!().tabstop;
let tabstop = config_handle!().tabstop;
let mut rline = Vec::with_capacity(max_chars);
// Iterating over characters not bytes as we need to account for multi-byte utf8
let line = self.txt.line(y);
Expand Down Expand Up @@ -828,7 +828,7 @@ impl Buffer {

fn handle_raw_key(&mut self, k: Key) -> Option<ActionOutcome> {
let (match_indent, expand_tab, tabstop) = {
let conf = config!();
let conf = config_handle!();
(conf.match_indent, conf.expand_tab, conf.tabstop)
};

Expand Down
5 changes: 2 additions & 3 deletions src/editor/actions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Editor actions in response to user input
use crate::{
buffer::{BufferKind, Buffers, MiniBuffer, MiniBufferSelection},
config,
config::Config,
die,
config_handle, die,
dot::{Cur, Dot, TextObject},
editor::Editor,
exec::{Addr, Address, Program},
Expand Down Expand Up @@ -174,7 +173,7 @@ impl Editor {
}

fn find_file_under_dir(&mut self, d: &Path) {
let cmd = config!().find_command.clone();
let cmd = config_handle!().find_command.clone();

let selection = match cmd.split_once(' ') {
Some((cmd, args)) => {
Expand Down
5 changes: 2 additions & 3 deletions src/editor/render.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! Rendering the user interface
use crate::{
buffer::{Buffer, MiniBufferState},
config,
config::ColorScheme,
die,
config_handle, die,
editor::Editor,
key::Key,
term::{Cursor, Style},
Expand Down Expand Up @@ -42,7 +41,7 @@ impl Editor {
.clamp_scroll(self.screen_rows, self.screen_cols);

let (cs, status_timeout) = {
let conf = config!();
let conf = config_handle!();
(conf.colorscheme, conf.status_timeout)
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub(crate) fn update_config(input: &str) -> Result<(), String> {

/// Get a read-only handle to the global Config data
#[macro_export]
macro_rules! config {
macro_rules! config_handle {
() => {{
$crate::CONFIG
.get_or_init(|| std::sync::RwLock::new($crate::Config::default()))
Expand Down
4 changes: 2 additions & 2 deletions src/mode/normal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! vim style normal mode
use crate::{
config,
config_handle,
dot::TextObject::*,
editor::{Action::*, Actions, ViewPort},
key::{Arrow::*, Key::*},
Expand Down Expand Up @@ -123,7 +123,7 @@ pub(crate) fn normal_mode() -> Mode {
cur_shape: CurShape::Block,
keymap,
handle_expired_pending: |keys| {
config!()
config_handle!()
.bindings
.get(keys)
.map(|prog| Actions::Single(ShellRun { cmd: prog.clone() }))
Expand Down

0 comments on commit 624fd28

Please sign in to comment.