Skip to content

Commit

Permalink
refactor: prefer vim.opt without nx.set when setting options
Browse files Browse the repository at this point in the history
enables autocompletions and for hover docs
  • Loading branch information
ttytm committed Nov 27, 2024
1 parent cbb126c commit 46c3ef8
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 99 deletions.
4 changes: 2 additions & 2 deletions lua/nxvim/client/fvim_loaded.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ vim.cmd([[
" Background composition
" 'none', 'transparent', 'blur' or 'acrylic'
FVimBackgroundComposition 'acrylic'
FVimBackgroundOpacity 0.85
FVimBackgroundComposition 'acrylic'
FVimBackgroundOpacity 0.85
FVimBackgroundAltOpacity 0.85
" Debug UI overlay
Expand Down
6 changes: 1 addition & 5 deletions lua/nxvim/client/gnvim.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
local opts = {
guifont = "JetBrainsMono Nerd Font Mono:h12.5",
}
vim.opt.guifont = "JetBrainsMono Nerd Font Mono:h12.5"

local function set_hl()
nx.hl({
Expand All @@ -12,5 +10,3 @@ local function set_hl()
end

nx.au({ { "UIEnter", once = true, callback = set_hl } })

return opts
6 changes: 1 addition & 5 deletions lua/nxvim/client/goneovim.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
local opts = {
fillchars__append = "vert: ",
}

return opts
vim.opt.fillchars:append("vert: ")
29 changes: 13 additions & 16 deletions lua/nxvim/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ end
nx.opts = {
float_win_border = "rounded",
transparency = true,
second_font = false,
second_font = true,
}

-- MacOS
Expand All @@ -36,29 +36,26 @@ end

local function init_gui()
-- General GUI options
local opts = {
fillchars__append = [[vert:│]],
guifont = vim.g.osx and "Hasklug Nerd Font Mono:h14" or "Hasklug Nerd Font Mono:h11",
guicursor = "n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait600-blinkoff800-blinkon900-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175",
linespace = vim.g.osx and 3 or 2,
winblend = 10,
pumblend = 10,
}
local opt = vim.opt
opt.fillchars:append("vert:│")
opt.guifont = vim.g.osx and "Hasklug Nerd Font Mono:h14" or "Hasklug Nerd Font Mono:h11"
opt.guicursor =
"n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,a:blinkwait600-blinkoff800-blinkon900-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175"
-- linespace = vim.g.osx and 3 or 2
opt.linespace = 4
opt.winblend = 10
opt.pumblend = 10

nx.opts.second_font = false

-- GUI Plugins
require("nxvim.plugins.size-matters")

return opts
end

function M.load_opts()
if not vim.g.loaded_gui then return end

local gui_opts = init_gui()
local client_opts = require("nxvim.client." .. vim.g.loaded_gui)

vim.schedule(function() nx.set(vim.tbl_deep_extend("keep", client_opts, gui_opts), vim.opt) end)
init_gui()
require("nxvim.client." .. vim.g.loaded_gui)
end

return M
16 changes: 7 additions & 9 deletions lua/nxvim/client/neovide.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
local opts = {
guifont = vim.g.osx and "Hasklug Nerd Font Mono:h16:#e-antialias:#h-none"
or "Hasklug Nerd Font Mono:h12:#e-antialias:#h-none",
-- guifont = "JetBrainsMono Nerd Font Mono:h11:#e-antialias:#h-none",
}
local opt = vim.opt
opt.guifont = vim.g.osx and "Hasklug Nerd Font Mono:h16:#e-antialias:#h-none"
-- or "Hasklug Nerd Font Mono:h12.5:#e-antialias:#h-none",
or "Hasklug Nerd Font Mono:h12.5"
-- guifont = "JetBrainsMono Nerd Font Mono:h12",
if vim.g.multigrid then
opts.winblend = 15
opts.pumblend = 15
opt.winblend = 15
opt.pumblend = 15
end

nx.set({
Expand All @@ -23,5 +23,3 @@ nx.set({
neovide_unlink_border_highlights = true,
-- neovide_scroll_animation_length = 0.35,
})

return opts
6 changes: 1 addition & 5 deletions lua/nxvim/client/nvui.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
local opts = {
fillchars__append = [[eob: ,fold: ,vert:│]],
}
vim.opt.fillchars:append("eob: ,fold: ,vert:│")

vim.cmd("NvuiOpacity 0.94")

nx.map({ "<S-lt>", "<gv", "v", desc = "Outdent" })

return opts
114 changes: 57 additions & 57 deletions lua/nxvim/options.lua
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
nx.set({
-- General
clipboard = "unnamedplus", -- use system clipboard
mouse = "a", -- allow mouse in all modes
showmode = false, -- print vim mode on enter
termguicolors = true, -- set term gui colors
timeoutlen = 350, -- time to wait for a mapped sequence to complete
title = true, -- show filename and path in application window title
sessionoptions__append = "globals",
laststatus = 3, -- global statusline
-- Auxiliary files
undofile = true, -- enable persistent undo
backup = false, -- create a backup file
swapfile = false, -- create a swap file
-- Command line
cmdheight = 0,
-- Completion menu
pumheight = 14, -- completion popup menu height
shortmess__append = "c", -- don't give completion-menu messages
-- Characters
fillchars__append = [[eob: ,vert:▏,vertright:▏,vertleft:▏,horiz:┈, fold: ,foldopen:,foldsep: ,foldclose:]],
listchars__append = [[space:⋅, tab: ░, trail:⋅, eol:↴]],
-- Gutter
number = true, -- show line numbers
numberwidth = 3, -- number column width - default "4"
relativenumber = true, -- set relative line numbers
signcolumn = "yes:2", -- use fixed width signcolumn - prevents text shift when adding signs
-- Search
hlsearch = true, -- highlight matches in previous search pattern
ignorecase = true, -- ignore case in search patterns
smartcase = true, -- use smart case, works in conjunction with ignorecase
-- Windows
equalalways = false, -- force equal window size on split
splitbelow = true, -- force horizontal splits below
splitright = true, -- force vertical splits right
-- Viewport
scrolloff = 7, -- number of lines to keep above / below cursor
sidescrolloff = 7, -- number of columns to keep left / right to cursor
cursorline = true, -- highlight the current line
colorcolumn = "120", -- column width indicator - default "80"
-- Text & line processing
list = false,
spelllang = "en", -- spell checking language
wrap = false, -- display lines as one long line
linebreak = true, -- do not wrap lines in the middle of words
whichwrap__append = "<,>,[,],h,l", -- move to previous / next line when reaching first / last character of line
-- Folds
foldlevel = 99,
foldlevelstart = 99,
foldcolumn = "1",
-- Indentation
expandtab = false, -- do not convert tabs to spaces
smartindent = true, -- smart auto indenting when starting a new line
shiftwidth = 0, -- number of spaces to use for (auto) indentation - zero = use tabstop value
tabstop = 3, -- number of spaces a tab counts for
}, vim.opt)
local o = vim.opt

-- Load client-specific opts after global opts
-- General
o.clipboard = "unnamedplus"
o.mouse = "a"
o.showmode = false
o.termguicolors = true
o.timeoutlen = 350
o.title = true
o.sessionoptions:append("globals")
o.laststatus = 3
-- Auxiliary files
o.undofile = true
o.backup = false
o.swapfile = false
-- Command line
o.cmdheight = 0
-- Completion menu
o.pumheight = 14
o.shortmess:append("c")
-- Characters
o.fillchars:append("eob: ,vert:▏,vertright:▏,vertleft:▏,horiz:┈, fold: ,foldopen:,foldsep: ,foldclose:")
o.listchars:append("space:⋅, tab: ░, trail:⋅, eol:↴")
-- Gutter
o.number = true
o.numberwidth = 3
o.relativenumber = true
o.signcolumn = "yes:2"
-- Search
o.hlsearch = true
o.ignorecase = true
o.smartcase = true
-- Windows
o.equalalways = false
o.splitbelow = true
o.splitright = true
-- Viewport
o.scrolloff = 7
o.sidescrolloff = 7
o.cursorline = true
o.colorcolumn = "120"
-- Text & line processing
o.list = false
o.spelllang = "en"
o.wrap = false
o.linebreak = true
o.whichwrap:append("<,>,[,],h,l")
-- Folds
o.foldlevel = 99
o.foldlevelstart = 99
o.foldcolumn = "1"
-- Indentation
o.expandtab = false
o.smartindent = true
o.shiftwidth = 0
o.tabstop = 3

-- Load client-specific opts and overwrites
require("nxvim.client").load_opts()

0 comments on commit 46c3ef8

Please sign in to comment.