Merge pull request #1155 from zed-industries/golang

Add Go support
This commit is contained in:
Max Brunsfeld 2022-06-09 14:18:37 -07:00 committed by GitHub
commit 87ba68e3ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 1229 additions and 277 deletions

View file

@ -25,6 +25,7 @@ pub struct Settings {
pub default_buffer_font_size: f32,
pub vim_mode: bool,
pub tab_size: u32,
pub hard_tabs: bool,
pub soft_wrap: SoftWrap,
pub preferred_line_length: u32,
pub format_on_save: bool,
@ -36,6 +37,7 @@ pub struct Settings {
#[derive(Clone, Debug, Default, Deserialize, JsonSchema)]
pub struct LanguageOverride {
pub tab_size: Option<u32>,
pub hard_tabs: Option<bool>,
pub soft_wrap: Option<SoftWrap>,
pub preferred_line_length: Option<u32>,
pub format_on_save: Option<bool>,
@ -84,6 +86,7 @@ impl Settings {
default_buffer_font_size: 15.,
vim_mode: false,
tab_size: 4,
hard_tabs: false,
soft_wrap: SoftWrap::None,
preferred_line_length: 80,
language_overrides: Default::default(),
@ -111,6 +114,13 @@ impl Settings {
.unwrap_or(self.tab_size)
}
pub fn hard_tabs(&self, language: Option<&str>) -> bool {
language
.and_then(|language| self.language_overrides.get(language))
.and_then(|settings| settings.hard_tabs)
.unwrap_or(self.hard_tabs)
}
pub fn soft_wrap(&self, language: Option<&str>) -> SoftWrap {
language
.and_then(|language| self.language_overrides.get(language))
@ -147,6 +157,7 @@ impl Settings {
default_buffer_font_size: 14.,
vim_mode: false,
tab_size: 4,
hard_tabs: false,
soft_wrap: SoftWrap::None,
preferred_line_length: 80,
format_on_save: true,