Set options per OS

This commit is contained in:
Eduardo Cueto-Mendoza 2024-05-07 11:59:07 +01:00
parent 5744a63865
commit 33e13ebba6
2 changed files with 225 additions and 61 deletions

View File

@ -7,10 +7,9 @@ if (f ~= nil) then
f:close() f:close()
end end
print(_G.MY_OS)
lsp.preset("recommended") lsp.preset("recommended")
if (_G.MY_OS == 'Linux') if (MY_OS == 'Linux')
then then
lsp.ensure_installed({ lsp.ensure_installed({
-- Replace these with whatever servers you want to install -- Replace these with whatever servers you want to install
@ -24,7 +23,7 @@ then
'rust_analyzer', 'rust_analyzer',
'zls' 'zls'
}) })
elseif (_G.MY_OS == 'FreeBSD') or (MY_OS == 'OpenBSD') elseif (MY_OS == 'FreeBSD') or (MY_OS == 'OpenBSD')
then then
lsp.ensure_installed({ lsp.ensure_installed({
-- Replace these with whatever servers you want to install -- Replace these with whatever servers you want to install
@ -32,7 +31,7 @@ then
'ocamllsp', 'ocamllsp',
'pylsp' 'pylsp'
}) })
elseif (_G.MY_OS == 'Darwin') elseif (MY_OS == 'Darwin')
then then
lsp.ensure_installed({ lsp.ensure_installed({
-- Replace these with whatever servers you want to install -- Replace these with whatever servers you want to install
@ -81,7 +80,7 @@ lsp.on_attach(function(client, bufnr)
end) end)
if (_G.MY_OS == 'Linux') if (MY_OS == 'Linux')
then then
-- Installed for Linux -- Installed for Linux
require('lspconfig').bashls.setup({}) require('lspconfig').bashls.setup({})
@ -162,7 +161,7 @@ then
require('lspconfig').zls.setup({}) require('lspconfig').zls.setup({})
elseif (_G.MY_OS == 'FreeBSD') or (_G.MY_OS == 'OpenBSD') elseif (MY_OS == 'FreeBSD') or (MY_OS == 'OpenBSD')
then then
-- Installed for BSD -- Installed for BSD
require('lspconfig').bashls.setup({}) require('lspconfig').bashls.setup({})
@ -185,7 +184,7 @@ then
require('lspconfig').zls.setup({}) require('lspconfig').zls.setup({})
elseif (_G.MY_OS == 'Darwin') elseif (MY_OS == 'Darwin')
then then
-- Installed for Linux -- Installed for Linux
require('lspconfig').clangd.setup({}) require('lspconfig').clangd.setup({})

View File

@ -1,73 +1,238 @@
vim.opt.guicursor = "" local f = io.popen("uname -s")
if (f ~= nil) then
MY_OS = f:read("*a")
MY_OS = string.gsub(MY_OS, "%s+", "")
f:close()
end
vim.opt.spelllang = 'en_gb' if (MY_OS == 'Linux')
vim.opt.spell = true then
-- on Linux
vim.opt.guicursor = ""
vim.opt.nu = true vim.opt.spelllang = 'en_gb'
vim.opt.relativenumber = true vim.opt.spell = true
vim.opt.tabstop = 4 vim.opt.nu = true
vim.opt.softtabstop = 4 vim.opt.relativenumber = true
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.wrap = true vim.opt.smartindent = true
-- Fonts
vim.opt.encoding = "utf-8"
vim.opt.guifont = "FiraCodeNerdFont-Regular:h10"
vim.opt.swapfile = false vim.opt.wrap = true
vim.opt.backup = false -- Fonts
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" vim.opt.encoding = "utf-8"
vim.opt.undofile = true vim.opt.guifont = "FiraCodeNerdFont-Regular:h10"
vim.opt.hlsearch = false vim.opt.swapfile = false
vim.opt.incsearch = true vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.termguicolors = true vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.scrolloff = 8 vim.opt.termguicolors = true
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50 vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.colorcolumn = "80" vim.opt.updatetime = 50
-- LSP options vim.opt.colorcolumn = "80"
vim.diagnostic.config({
-- LSP options
vim.diagnostic.config({
virtual_text = false virtual_text = false
}) })
-- Show line diagnostics automatically in hover window -- Show line diagnostics automatically in hover window
vim.o.updatetime = 250 vim.o.updatetime = 250
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
-- Vimtex options: -- Vimtex options:
--vim.g.vimtex_view_method = "zathura" vim.g.vimtex_view_method = "zathura"
--vim.g.vimtex_general_viewer = "zathura" vim.g.vimtex_general_viewer = "zathura"
vim.g.vimtex_view_method = "skim" vim.g.vimtex_quickfix_mode = 0
vim.g.vimtex_general_viewer = "skim"
vim.g.vimtex_quickfix_mode = 0
-- OBSD options -- Ignore mappings
--vim.g.vimtex_compiler_latexmk={ 'cmd': '' } vim.g.vimtex_mappings_enabled = 1
-- Ignore mappings ---- Auto Indent
vim.g.vimtex_mappings_enabled = 1 vim.g["vimtex_indent_enabled"] = 1
---- Auto Indent ---- Syntax highlighting
--vim.g["vimtex_indent_enabled"] = 1 vim.g.vimtex_syntax_enabled = 0
---- Syntax highlighting -- Error suppression:
vim.g.vimtex_syntax_enabled = 0 vim.g.vimtex_log_ignore = ({
-- Error suppression:
vim.g.vimtex_log_ignore = ({
"Underfull", "Underfull",
"Overfull", "Overfull",
"specifier changed to", "specifier changed to",
"Token not allowed in a PDF string", "Token not allowed in a PDF string",
}) })
-- Python provider
vim.g.python3_host_prog = "/usr/share/pyenv/shims/python"
elseif (MY_OS == 'FreeBSD') or (MY_OS == 'OpenBSD')
then
-- on BSD
vim.opt.guicursor = ""
vim.opt.spelllang = 'en_gb'
vim.opt.spell = true
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = true
-- Fonts
vim.opt.encoding = "utf-8"
vim.opt.guifont = "FiraCodeNerdFont-Regular:h10"
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
vim.opt.colorcolumn = "80"
-- LSP options
vim.diagnostic.config({
virtual_text = false
})
-- Show line diagnostics automatically in hover window
vim.o.updatetime = 250
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
-- Vimtex options:
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_general_viewer = "zathura"
vim.g.vimtex_quickfix_mode = 0
-- OBSD options
--vim.g.vimtex_compiler_latexmk={ 'cmd': '' }
-- Ignore mappings
vim.g.vimtex_mappings_enabled = 1
---- Auto Indent
vim.g["vimtex_indent_enabled"] = 1
---- Syntax highlighting
vim.g.vimtex_syntax_enabled = 0
-- Error suppression:
vim.g.vimtex_log_ignore = ({
"Underfull",
"Overfull",
"specifier changed to",
"Token not allowed in a PDF string",
})
-- Python provider
vim.g.python3_host_prog = "/usr/local/share/pyenv/shims/python"
elseif (MY_OS == 'Darwin')
then
-- on MacOS
vim.opt.guicursor = ""
vim.opt.spelllang = 'en_gb'
vim.opt.spell = true
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.wrap = true
-- Fonts
vim.opt.encoding = "utf-8"
vim.opt.guifont = "FiraCodeNerdFont-Regular:h10"
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.opt.signcolumn = "yes"
vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
vim.opt.colorcolumn = "80"
-- LSP options
vim.diagnostic.config({
virtual_text = false
})
-- Show line diagnostics automatically in hover window
vim.o.updatetime = 250
vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
-- Vimtex options:
vim.g.vimtex_view_method = "skim"
vim.g.vimtex_general_viewer = "skim"
vim.g.vimtex_quickfix_mode = 0
-- Ignore mappings
vim.g.vimtex_mappings_enabled = 1
---- Auto Indent
vim.g["vimtex_indent_enabled"] = 1
---- Syntax highlighting
vim.g.vimtex_syntax_enabled = 0
-- Error suppression:
vim.g.vimtex_log_ignore = ({
"Underfull",
"Overfull",
"specifier changed to",
"Token not allowed in a PDF string",
})
-- Python provider
vim.g.python3_host_prog = "/usr/local/share/pyenv/shims/python"
else
print('Should never be here LSP')
end