From ccd6fa7cf9a072653580c454bc090aec9929ee72 Mon Sep 17 00:00:00 2001 From: David Ponte Date: Mon, 12 May 2025 16:05:38 +0200 Subject: [PATCH] fix: enable Nerd Font support and adjust font variant settings --- after/ftplugin/c.lua | 44 ++++++++++++++++++++++++++++++++++++++++++++ init.lua | 8 +++----- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/after/ftplugin/c.lua b/after/ftplugin/c.lua index 49d6e7d1..d21fe8c6 100644 --- a/after/ftplugin/c.lua +++ b/after/ftplugin/c.lua @@ -1,6 +1,50 @@ local set = vim.opt_local +<<<<<<< Updated upstream set.shiftwidth = 4 set.tabstop = 4 vim.g.sleuth_automatic = 0 +======= +-- Use tabs instead of spaces +set.expandtab = false -- Use real tabs, not spaces +set.shiftwidth = 4 -- Size of an indent +set.tabstop = 4 -- Size of a tab +set.softtabstop = 0 -- Disable softtabstop +>>>>>>> Stashed changes set.commentstring = '/* %s */' + +-- Define a custom command ':IntMain' that inserts int main() {} template +vim.api.nvim_create_user_command('IntMain', function() + local current_line = vim.api.nvim_win_get_cursor(0)[1] + local lines = { + '#include ', + '', + 'int main ()', + '{', + ' ', + ' printf();', + ' return 0;', + '}', + } + vim.api.nvim_buf_set_lines(0, current_line - 1, current_line - 1, false, lines) + -- Position cursor inside the function body + vim.api.nvim_win_set_cursor(0, { current_line + 1, 4 }) + end, {}) + + vim.api.nvim_create_user_command('Libft', function() + local current_line = vim.api.nvim_win_get_cursor(0)[1] + vim.api.nvim_buf_set_lines(0, current_line - 1, current_line - 1, false, { + '#include "libft.h"', + }) + end, {}) + + -- Force these settings after any other scripts might have changed them + vim.api.nvim_create_autocmd("FileType", { + pattern = "c", + callback = function() + vim.opt_local.tabstop = 4 + vim.opt_local.shiftwidth = 4 + vim.opt_local.softtabstop = 4 + vim.opt_local.expandtab = true + end + }) \ No newline at end of file diff --git a/init.lua b/init.lua index 984c90b7..2e32c731 100644 --- a/init.lua +++ b/init.lua @@ -11,7 +11,7 @@ vim.g.loaded_netrwPlugin = 1 vim.opt.termguicolors = true -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- Load options from options.lua require 'options' @@ -708,8 +708,8 @@ require('lazy').setup({ appearance = { -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font' -- Adjusts spacing to ensure icons are aligned - -- nerd_font_variant = 'mono', - nerd_font_variant = 'normal', + nerd_font_variant = 'mono', + -- nerd_font_variant = 'normal', }, completion = { @@ -797,7 +797,6 @@ require('lazy').setup({ end, }, { - 'polirritmico/monokai-nightasty.nvim', lazy = false, priority = 1000, @@ -846,7 +845,6 @@ require('lazy').setup({ { 'tanvirtin/monokai.nvim', config = function() - -- pcall(vim.cmd, [[colorscheme monokai]]) require('monokai').setup { palette = require('monokai').classic } end, },