Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chezmoiexternal.toml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{- $isTermux := or (hasPrefix "/data/data/com.termux/" .chezmoi.homeDir) (hasPrefix "/data/data/com.termux/" (env "PREFIX")) -}}
{{- if $isTermux }}
[".termux/font.ttf"]
type = "file"
url = "https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Meslo/M/Regular/MesloLGMNerdFontMono-Regular.ttf"
refreshPeriod = "168h"
{{- end }}
64 changes: 54 additions & 10 deletions dot_config/nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ vim.g.maplocalleader = ' '

local path_sep = vim.fn.has 'win32' == 1 and ';' or ':'

local function path_starts_with(path, prefix) return type(path) == 'string' and path ~= '' and path:sub(1, #prefix) == prefix end

local is_termux = path_starts_with(vim.env.PREFIX, '/data/data/com.termux/') or path_starts_with(vim.fn.expand '~', '/data/data/com.termux/')
vim.g.dot_is_termux = is_termux
vim.g.dot_mobile_nvim = is_termux or vim.env.DOT_MOBILE_NVIM == '1'

local function prepend_path(dir)
if vim.fn.isdirectory(dir) == 1 and not string.find(vim.env.PATH or '', dir, 1, true) then vim.env.PATH = dir .. path_sep .. (vim.env.PATH or '') end
end
Expand All @@ -118,7 +124,7 @@ if vim.fn.has 'win32' == 1 then
prepend_path(dir)
end
end
else
elseif not vim.g.dot_mobile_nvim then
-- GUI/IDE launches often skip shell profile hooks; mise shims expose global tools (e.g. vale).
prepend_path(vim.fn.expand '~/.local/share/mise/shims')
end
Expand Down Expand Up @@ -148,6 +154,20 @@ vim.o.showmode = false
-- Schedule the setting after `UiEnter` because it can increase startup-time.
-- Remove this option if you want your OS clipboard to remain independent.
-- See `:help 'clipboard'`
if vim.g.dot_is_termux and vim.fn.executable 'termux-clipboard-set' == 1 and vim.fn.executable 'termux-clipboard-get' == 1 then
vim.g.clipboard = {
name = 'termux-clipboard',
copy = {
['+'] = 'termux-clipboard-set',
['*'] = 'termux-clipboard-set',
},
paste = {
['+'] = 'termux-clipboard-get',
['*'] = 'termux-clipboard-get',
},
cache_enabled = 0,
}
end
vim.schedule(function() vim.o.clipboard = 'unnamedplus' end)

-- Enable break indent
Expand Down Expand Up @@ -176,7 +196,7 @@ vim.opt.fillchars:append { vert = '┃' }

-- Per-character highlights inside changed diff lines (vimdiff, Gitsigns diffthis, Diffview, etc.)
-- See :help 'diffopt'
if not vim.o.diffopt:find('inline:', 1, true) then vim.opt.diffopt:append 'inline:char' end
if vim.fn.has 'nvim-0.12' == 1 and not vim.o.diffopt:find('inline:', 1, true) then vim.opt.diffopt:append 'inline:char' end

-- Sets how neovim will display certain whitespace characters in the editor.
-- See `:help 'list'`
Expand Down Expand Up @@ -212,20 +232,23 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')

-- Diagnostic Config & Keymaps
-- See :help vim.diagnostic.Opts
vim.diagnostic.config {
local diagnostic_config = {
update_in_insert = false,
severity_sort = true,
float = { border = 'rounded', source = 'if_many' },
underline = { severity = vim.diagnostic.severity.ERROR },

-- Can switch between these as you prefer
virtual_text = true, -- Text shows up at the end of the line
virtual_lines = false, -- Teest shows up underneath the line, with virtual lines

-- Auto open the float, so you can easily read the errors when jumping with `[d` and `]d`
jump = { float = true },
}

if vim.fn.has 'nvim-0.11' == 1 then
diagnostic_config.virtual_lines = false -- Text shows up underneath the line, with virtual lines
diagnostic_config.jump = { float = true } -- Auto-open diagnostic float when jumping with `[d` and `]d`
end

vim.diagnostic.config(diagnostic_config)

vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })

-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
Expand Down Expand Up @@ -259,7 +282,10 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
vim.api.nvim_create_autocmd('TextYankPost', {
desc = 'Highlight when yanking (copying) text',
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
callback = function() vim.hl.on_yank() end,
callback = function()
local highlight = vim.hl or vim.highlight
if highlight and highlight.on_yank then highlight.on_yank() end
end,
})

-- [[ Install `lazy.nvim` plugin manager ]]
Expand Down Expand Up @@ -1021,6 +1047,7 @@ require('lazy').setup({
{
-- Main LSP Configuration
'neovim/nvim-lspconfig',
enabled = not vim.g.dot_mobile_nvim,
dependencies = {
-- Automatically install LSPs and related tools to stdpath for Neovim
-- Mason must be loaded before its dependents so we need to set it up here.
Expand Down Expand Up @@ -1506,6 +1533,7 @@ require('lazy').setup({

{
'nvim-neotest/neotest',
enabled = not vim.g.dot_mobile_nvim,
dependencies = {
'nvim-neotest/nvim-nio',
'nvim-lua/plenary.nvim',
Expand Down Expand Up @@ -1593,7 +1621,7 @@ require('lazy').setup({
-- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows.
if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end
if vim.fn.has 'win32' == 1 or vim.g.dot_mobile_nvim or vim.fn.executable 'make' == 0 then return end
return 'make install_jsregexp'
end)(),
dependencies = {
Expand Down Expand Up @@ -1675,6 +1703,7 @@ require('lazy').setup({

{
'juxt/nvim-allium',
enabled = not vim.g.dot_mobile_nvim,
event = 'VeryLazy',
opts = {},
dependencies = {
Expand Down Expand Up @@ -1784,6 +1813,21 @@ require('lazy').setup({
'vimdoc',
'yaml',
}
if vim.g.dot_mobile_nvim then
parsers = {
'bash',
'diff',
'json',
'lua',
'markdown',
'markdown_inline',
'query',
'toml',
'vim',
'vimdoc',
'yaml',
}
end
local filetypes = vim.list_extend(vim.deepcopy(parsers), { 'javascriptreact', 'typescriptreact' })

local function chezmoi_template_language(bufnr)
Expand Down Expand Up @@ -1829,7 +1873,7 @@ require('lazy').setup({
{}
)

if vim.fn.executable 'tree-sitter' == 1 then require('nvim-treesitter').install(parsers) end
if not vim.g.dot_mobile_nvim and vim.fn.executable 'tree-sitter' == 1 then require('nvim-treesitter').install(parsers) end
vim.api.nvim_create_autocmd('FileType', {
pattern = filetypes,
callback = function() pcall(vim.treesitter.start) end,
Expand Down
1 change: 1 addition & 0 deletions dot_config/nvim/lua/custom/plugins/ai_assistant.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
'olimorris/codecompanion.nvim',
enabled = not vim.g.dot_mobile_nvim,
cmd = { 'CodeCompanion', 'CodeCompanionActions', 'CodeCompanionChat' },
dependencies = {
'nvim-lua/plenary.nvim',
Expand Down
1 change: 1 addition & 0 deletions dot_config/nvim/lua/custom/plugins/ai_cli.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
'akinsho/toggleterm.nvim',
enabled = not vim.g.dot_mobile_nvim,
version = '*',
opts = {
direction = 'float',
Expand Down
3 changes: 2 additions & 1 deletion dot_config/nvim/lua/custom/plugins/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ return {

{
'iamcco/markdown-preview.nvim',
enabled = not vim.g.dot_mobile_nvim,
cmd = { 'MarkdownPreviewToggle', 'MarkdownPreview', 'MarkdownPreviewStop' },
ft = { 'markdown' },
build = 'cd app && npm install',
Expand Down Expand Up @@ -129,7 +130,7 @@ return {

{
'3rd/image.nvim',
cond = terminal_graphics_supported,
cond = function() return not vim.g.dot_mobile_nvim and terminal_graphics_supported() end,
event = 'VeryLazy',
build = false,
opts = {
Expand Down
4 changes: 4 additions & 0 deletions dot_config/nvim/lua/custom/plugins/typescript.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
'pmizio/typescript-tools.nvim',
enabled = not vim.g.dot_mobile_nvim,
dependencies = {
'nvim-lua/plenary.nvim',
'neovim/nvim-lspconfig',
Expand Down Expand Up @@ -63,6 +64,7 @@ return {

{
'mfussenegger/nvim-lint',
enabled = not vim.g.dot_mobile_nvim,
event = { 'BufReadPre', 'BufNewFile' },
config = function()
local lint = require 'lint'
Expand Down Expand Up @@ -123,12 +125,14 @@ return {

{
'dmmulroy/ts-error-translator.nvim',
enabled = not vim.g.dot_mobile_nvim,
ft = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact' },
opts = {},
},

{
'windwp/nvim-ts-autotag',
enabled = not vim.g.dot_mobile_nvim,
ft = { 'javascriptreact', 'typescriptreact', 'html' },
opts = {},
},
Expand Down
1 change: 1 addition & 0 deletions dot_config/nvim/lua/custom/plugins/vale.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ return {
},
{
'mfussenegger/nvim-lint',
enabled = not vim.g.dot_mobile_nvim,
keys = {
{
'<leader>,a',
Expand Down
3 changes: 3 additions & 0 deletions dot_config/nvim/lua/custom/plugins/web_service_dev.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
return {
{
'folke/which-key.nvim',
enabled = not vim.g.dot_mobile_nvim,
optional = true,
opts = function(_, opts)
opts.spec = opts.spec or {}
Expand All @@ -12,6 +13,8 @@ return {
'nvim-lua/plenary.nvim',
lazy = false,
config = function()
if vim.g.dot_mobile_nvim then return end

local uv = vim.uv or vim.loop

local function detect_project_root()
Expand Down
Loading