Created
December 12, 2024 15:16
-
-
Save abbood/3cb7ab1ffb6cd15cdc7856d8725591e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Read the docs: https://www.lunarvim.org/docs/configuration | |
-- Example configs: https://github.com/LunarVim/starter.lvim | |
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6 | |
-- Forum: https://www.reddit.com/r/lunarvim/ | |
-- Discord: https://discord.com/invite/Xb9B4Ny | |
local opts = { noremap = true, silent = true } | |
local map = vim.api.nvim_set_keymap | |
lvim.leader = "," | |
-- Enable formatting on save | |
lvim.format_on_save.enabled = true | |
vim.api.nvim_create_autocmd("ColorScheme", { | |
callback = function() | |
print("ColorScheme changed to: " .. vim.g.colors_name) | |
end | |
}) | |
vim.opt.foldmethod = "expr" | |
vim.opt.foldexpr = "nvim_treesitter#foldexpr()" | |
vim.opt.foldlevel = 99 | |
-- Configure null-ls for formatting | |
local formatters = require "lvim.lsp.null-ls.formatters" | |
formatters.setup { | |
{ | |
command = "prettier", | |
filetypes = { | |
"javascript", | |
"typescript", | |
"css", | |
"scss", | |
"html", | |
"json", | |
"yaml", | |
"markdown", | |
"graphql", | |
"md", | |
"txt", | |
}, | |
}, | |
} | |
-- lvim.keys.normal_mode["<C-j>"] = ":Telescope find_files<CR>" // see custom_find_files | |
lvim.keys.normal_mode["<C-n>"] = ":NvimTreeToggle<CR>" | |
lvim.keys.normal_mode["<C-h>"] = ":Telescope lsp_document_symbols<CR>" | |
--lvim.keys.normal_mode["<C-f>"] = ":lua require('telescope.builtin').buffers({ sort_mru = true, ignore_current_buffer = true })<CR>" | |
--lvim.keys.normal_mode["<C-f>"] = function() | |
-- require('telescope.builtin').buffers({ | |
-- sort_mru = true, | |
-- ignore_current_buffer = true, | |
-- layout_strategy = 'vertical', | |
-- layout_config = { | |
-- height = 0.9, | |
-- preview_height = 0.6, | |
-- mirror = true | |
-- } | |
-- }) | |
--end | |
--vim.g.fzf_layout = { | |
-- window = { | |
-- width = 0.9, | |
-- height = 0.9, | |
-- border = 'rounded' | |
-- } | |
--} | |
-- Set up the keybinding for buffers | |
lvim.keys.normal_mode["<C-f>"] = ":Buffers<CR>" | |
-- Optional: Configure FZF colors to match your theme | |
vim.g.fzf_colors = { | |
['fg'] = { 'fg', 'Normal' }, | |
['bg'] = { 'bg', 'Normal' }, | |
['hl'] = { 'fg', 'Special' }, | |
['fg+'] = { 'fg', 'CursorLine', 'CursorColumn', 'Normal' }, | |
['bg+'] = { 'bg', 'CursorLine', 'CursorColumn' }, | |
['hl+'] = { 'fg', 'Statement' }, | |
['info'] = { 'fg', 'Type' }, | |
['border'] = { 'fg', 'Normal' }, | |
['prompt'] = { 'fg', 'Function' }, | |
['pointer'] = { 'fg', 'Exception' }, | |
['marker'] = { 'fg', 'Keyword' }, | |
['spinner'] = { 'fg', 'Label' }, | |
['header'] = { 'fg', 'Comment' } | |
} | |
-- Add this to ensure fzf window uses your terminal background | |
vim.g.fzf_layout = { | |
window = { | |
width = 0.9, | |
height = 0.9, | |
border = 'rounded', | |
highlight = 'Normal' | |
} | |
} | |
-- cycle through previously accessed buffers -- the above didn't play nice with lunar | |
--lvim.keys.normal_mode["<C-f>"] = "<C-^>" | |
-- | |
lvim.keys.normal_mode["<Leader>b"] = ":Gitsigns blame_line<CR>" | |
lvim.keys.normal_mode["<leader>mm"] = ":lua require('codewindow').toggle_minimap()<CR>" | |
lvim.keys.normal_mode["<leader>r"] = ":lua vim.wo.wrap = not vim.wo.wrap<CR>" | |
lvim.keys.normal_mode["gg"] = ":Telescope live_grep<CR>" -- conflicts with go to first line (nvim default) | |
lvim.keys.normal_mode["ggg"] = ":Telescope resume<CR>" | |
lvim.keys.normal_mode["gj"] = ":Telescope current_buffer_fuzzy_find<CR>" | |
lvim.keys.normal_mode["gk"] = ":lua require('telescope.builtin').grep_string{}<cr>" | |
-- current buffer errors | |
lvim.keys.normal_mode["ge"] = "<cmd>Telescope diagnostics bufnr=0<CR>" | |
-- all errors | |
lvim.keys.normal_mode["ga"] = "<cmd>Telescope diagnostics<CR>" | |
lvim.keys.normal_mode["<C-c>"] = ":cclose<CR>" | |
lvim.keys.normal_mode["gv"] = function() | |
vim.cmd("vsplit") | |
vim.lsp.buf.definition() | |
end | |
-- lvim.keys.normal_mode["gh"] = {"<cmd>lua vim.diagnostic.open_float()<CR>", { silent = true, noremap = true, desc = "Open diagnostic float" }} | |
lvim.keys.normal_mode["gh"] = { | |
function() | |
-- Open the diagnostic float | |
vim.diagnostic.open_float() | |
-- Get the diagnostic message at the cursor | |
local diagnostics = vim.diagnostic.get(0, { lnum = vim.api.nvim_win_get_cursor(0)[1] - 1 }) | |
if #diagnostics > 0 then | |
local message = diagnostics[1].message | |
-- Copy the message to the clipboard | |
vim.fn.setreg('+', message) | |
vim.fn.setreg('"', message) | |
-- Optionally, provide feedback to the user | |
print("Diagnostic message copied to clipboard") | |
else | |
print("No diagnostic message at cursor") | |
end | |
end, | |
{ silent = true, noremap = true, desc = "Open diagnostic float and copy to clipboard" } | |
} | |
vim.api.nvim_set_keymap('n', '<C-l>', ':NvimTreeResize +10<CR>', { noremap = true, silent = true }) | |
vim.api.nvim_set_keymap('n', '<S-l>', ':NvimTreeResize -10<CR>', { noremap = true, silent = true }) -- leader l in nvim | |
lvim.builtin.telescope.defaults = { | |
layout_strategy = "horizontal", | |
layout_config = { | |
horizontal = { | |
preview_width = 0.7, | |
results_width = 0.3, | |
mirror = false, | |
}, | |
vertical = { | |
mirror = false, | |
}, | |
width = 0.95, | |
height = 0.95, | |
preview_cutoff = 120, | |
}, | |
} | |
-- Create a custom find_files command without preview | |
local telescope = require('telescope.builtin') | |
_G.custom_find_files = function() | |
telescope.find_files({ | |
previewer = false, | |
layout_config = { | |
horizontal = { | |
width = 0.5, -- Make the window narrower since we don't have preview | |
height = 0.5, | |
} | |
} | |
}) | |
end | |
-- Bind the custom command to your shortcut | |
lvim.keys.normal_mode["<C-j>"] = ":lua custom_find_files()<CR>" | |
-- not yet working | |
local home = os.getenv("HOME") | |
vim.opt.runtimepath:append(home .. "/.local/share/lunarvim/site/pack/packer/start/typewriter-vim") | |
-- | |
-- | |
-- Add to your config.lua | |
-- First unbind the default K mapping | |
lvim.lsp.buffer_mappings.normal_mode["K"] = nil | |
-- Alternative syntax if the above doesn't work | |
lvim.keys.normal_mode["K"] = "<cmd>lua require('telescope.builtin').grep_string()<cr>" | |
-- In your config.lua file | |
-- | |
-- | |
lvim.plugins = { | |
{ | |
"junegunn/fzf", | |
build = function() | |
vim.fn["fzf#install"]() | |
end | |
}, | |
{ | |
"junegunn/fzf.vim" | |
} | |
} | |
vim.g.fzf_colors = { | |
['fg'] = { 'fg', 'Normal' }, | |
['bg'] = { 'bg', 'Normal' }, | |
['hl'] = { 'fg', 'Comment' }, | |
['fg+'] = { 'fg', 'CursorLine', 'CursorColumn', 'Normal' }, | |
['bg+'] = { 'bg', 'CursorLine', 'CursorColumn' }, | |
['hl+'] = { 'fg', 'Statement' }, | |
['info'] = { 'fg', 'PreProc' }, | |
['border'] = { 'fg', 'Ignore' }, | |
['prompt'] = { 'fg', 'Conditional' }, | |
['pointer'] = { 'fg', 'Exception' }, | |
['marker'] = { 'fg', 'Keyword' }, | |
['spinner'] = { 'fg', 'Label' }, | |
['header'] = { 'fg', 'Comment' } | |
} | |
-- Paste in visual mode while preserving clipboard contents | |
lvim.keys.visual_mode["<Leader>p"] = [["_dP]] | |
-- lvim.colorscheme = "gruvbox-material" | |
-- | |
lvim.builtin.nvimtree.setup.update_cwd = false | |
lvim.builtin.nvimtree.setup.respect_buf_cwd = true | |
lvim.builtin.nvimtree.setup.sync_root_with_cwd = true | |
lvim.builtin.nvimtree.setup.filters = { | |
custom = { | |
"^.git$", | |
"^.DS_Store$", | |
"^node_modules$", | |
"^.next$", | |
".env", | |
"^.gitignore$", | |
"^.env.*$", | |
"^dist$", | |
"^build$" | |
}, | |
exclude = { | |
".env.example", | |
".gitignore" | |
} | |
} | |
lvim.builtin.nvimtree.setup.git.ignore = true | |
vim.keymap.set('n', '<leader>yy', function() | |
local relative_path = vim.fn.fnamemodify(vim.fn.expand('%'), ':.') | |
vim.fn.setreg('+', relative_path) | |
vim.notify('Copied: ' .. relative_path) | |
end, { desc = 'Copy relative file path' }) | |
vim.filetype.add({ | |
extension = { | |
bru = "http", | |
}, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment