@@ -87,11 +87,11 @@ P.S. You can delete this when you're done too. It's your config now! :)
8787-- Set <space> as the leader key
8888-- See `:help mapleader`
8989-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
90- vim .g .mapleader = ' '
91- vim .g .maplocalleader = ' '
90+ vim .g .mapleader = ' ` '
91+ vim .g .maplocalleader = ' ` '
9292
9393-- Set to true if you have a Nerd Font installed and selected in the terminal
94- vim .g .have_nerd_font = false
94+ vim .g .have_nerd_font = true
9595
9696-- [[ Setting options ]]
9797-- See `:help vim.o`
@@ -150,7 +150,7 @@ vim.o.splitbelow = true
150150-- See `:help lua-options`
151151-- and `:help lua-options-guide`
152152vim .o .list = true
153- vim .opt .listchars = { tab = ' » ' , trail = ' · ' , nbsp = ' ␣' }
153+ vim .opt .listchars = { tab = ' ' , nbsp = ' ␣' }
154154
155155-- Preview substitutions live, as you type!
156156vim .o .inccommand = ' split'
@@ -166,9 +166,46 @@ vim.o.scrolloff = 10
166166-- See `:help 'confirm'`
167167vim .o .confirm = true
168168
169+ -- Tab settings
170+ vim .o .tabstop = 2 -- Number of spaces a tab counts for
171+ vim .o .shiftwidth = 2 -- Number of spaces for auto-indent
172+ vim .o .expandtab = true -- Convert tabs to spaces
173+ vim .o .softtabstop = 2 -- Number of spaces for <Tab> key
174+
169175-- [[ Basic Keymaps ]]
170176-- See `:help vim.keymap.set()`
171177
178+ -- Command+C/V/X for copy/paste/cut (Mac style)
179+ vim .keymap .set (' v' , ' <D-c>' , ' "+y' , { desc = ' Copy to clipboard' })
180+ vim .keymap .set (' n' , ' <D-v>' , ' "+p' , { desc = ' Paste from clipboard' })
181+ vim .keymap .set (' i' , ' <D-v>' , ' <C-r>+' , { desc = ' Paste from clipboard' })
182+ vim .keymap .set (' v' , ' <D-x>' , ' "+d' , { desc = ' Cut to clipboard' })
183+
184+ -- Toggle GitHub Copilot with F16
185+ local copilot_enabled = true
186+ vim .keymap .set (' n' , ' <F16>' , function ()
187+ if copilot_enabled then
188+ vim .cmd ' Copilot disable'
189+ copilot_enabled = false
190+ print ' Copilot disabled'
191+ else
192+ vim .cmd ' Copilot enable'
193+ copilot_enabled = true
194+ print ' Copilot enabled'
195+ end
196+ end , { desc = ' Toggle GitHub Copilot' })
197+ vim .keymap .set (' i' , ' <F16>' , function ()
198+ if copilot_enabled then
199+ vim .cmd ' Copilot disable'
200+ copilot_enabled = false
201+ print ' Copilot disabled'
202+ else
203+ vim .cmd ' Copilot enable'
204+ copilot_enabled = true
205+ print ' Copilot enabled'
206+ end
207+ end , { desc = ' Toggle GitHub Copilot' })
208+
172209-- Clear highlights on search when pressing <Esc> in normal mode
173210-- See `:help hlsearch`
174211vim .keymap .set (' n' , ' <Esc>' , ' <cmd>nohlsearch<CR>' )
@@ -247,7 +284,15 @@ rtp:prepend(lazypath)
247284-- NOTE: Here is where you install your plugins.
248285require (' lazy' ).setup ({
249286 -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
250- ' NMAC427/guess-indent.nvim' , -- Detect tabstop and shiftwidth automatically
287+ {
288+ ' NMAC427/guess-indent.nvim' ,
289+ opts = {},
290+ }, -- Detect tabstop and shiftwidth automatically
291+
292+ -- GitHub Copilot
293+ {
294+ ' github/copilot.vim' ,
295+ },
251296
252297 -- NOTE: Plugins can also be added by using a table,
253298 -- with the first argument being the link and the following
@@ -281,6 +326,12 @@ require('lazy').setup({
281326 topdelete = { text = ' ‾' },
282327 changedelete = { text = ' ~' },
283328 },
329+ current_line_blame = true ,
330+ current_line_blame_opts = {
331+ virt_text = false ,
332+ delay = 500 ,
333+ },
334+ current_line_blame_formatter = ' <author>, <author_time:%R>' ,
284335 },
285336 },
286337
@@ -426,39 +477,75 @@ require('lazy').setup({
426477
427478 -- See `:help telescope.builtin`
428479 local builtin = require ' telescope.builtin'
429- vim .keymap .set (' n' , ' <leader>sh' , builtin .help_tags , { desc = ' [S]earch [H]elp' })
430- vim .keymap .set (' n' , ' <leader>sk' , builtin .keymaps , { desc = ' [S]earch [K]eymaps' })
431- vim .keymap .set (' n' , ' <leader>sf' , builtin .find_files , { desc = ' [S]earch [F]iles' })
432- vim .keymap .set (' n' , ' <leader>ss' , builtin .builtin , { desc = ' [S]earch [S]elect Telescope' })
433- vim .keymap .set (' n' , ' <leader>sw' , builtin .grep_string , { desc = ' [S]earch current [W]ord' })
434- vim .keymap .set (' n' , ' <leader>sg' , builtin .live_grep , { desc = ' [S]earch by [G]rep' })
435- vim .keymap .set (' n' , ' <leader>sd' , builtin .diagnostics , { desc = ' [S]earch [D]iagnostics' })
436- vim .keymap .set (' n' , ' <leader>sr' , builtin .resume , { desc = ' [S]earch [R]esume' })
437- vim .keymap .set (' n' , ' <leader>s.' , builtin .oldfiles , { desc = ' [S]earch Recent Files ("." for repeat)' })
438- vim .keymap .set (' n' , ' <leader><leader>' , builtin .buffers , { desc = ' [ ] Find existing buffers' })
439480
481+ -- Helper to launch Telescope from a non-Neo-tree window
482+ local function smart_telescope_launch (func )
483+ return function (...)
484+ if vim .bo .filetype == ' neo-tree' then
485+ local neotree_win = vim .api .nvim_get_current_win ()
486+ local wins = vim .api .nvim_list_wins ()
487+ local target_win = nil
488+ for _ , win in ipairs (wins ) do
489+ local config = vim .api .nvim_win_get_config (win )
490+ if config .relative == ' ' then
491+ local buf = vim .api .nvim_win_get_buf (win )
492+ local ft = vim .api .nvim_get_option_value (' filetype' , { buf = buf })
493+ if ft ~= ' neo-tree' then
494+ target_win = win
495+ break
496+ end
497+ end
498+ end
499+
500+ if target_win then
501+ vim .api .nvim_win_set_width (neotree_win , 30 )
502+ vim .api .nvim_set_current_win (target_win )
503+ else
504+ vim .cmd ' vsplit'
505+ vim .api .nvim_win_set_width (neotree_win , 30 )
506+ end
507+ end
508+ if type (func ) == ' function' then
509+ func (... )
510+ end
511+ end
512+ end
513+
514+ vim .keymap .set (' n' , ' <leader>sh' , smart_telescope_launch (builtin .help_tags ), { desc = ' [S]earch [H]elp' })
515+ vim .keymap .set (' n' , ' <leader>sk' , smart_telescope_launch (builtin .keymaps ), { desc = ' [S]earch [K]eymaps' })
516+ vim .keymap .set (' n' , ' <leader>sf' , smart_telescope_launch (builtin .find_files ), { desc = ' [S]earch [F]iles' })
517+ vim .keymap .set (' n' , ' <D-p>' , smart_telescope_launch (builtin .find_files ), { desc = ' Search Files' })
518+ vim .keymap .set (' n' , ' <leader>ss' , smart_telescope_launch (builtin .builtin ), { desc = ' [S]earch [S]elect Telescope' })
519+ vim .keymap .set (' n' , ' <leader>sw' , smart_telescope_launch (builtin .grep_string ), { desc = ' [S]earch current [W]ord' })
520+ vim .keymap .set (' n' , ' <leader>sg' , smart_telescope_launch (builtin .live_grep ), { desc = ' [S]earch by [G]rep' })
521+ vim .keymap .set (' n' , ' <leader>sd' , smart_telescope_launch (builtin .diagnostics ), { desc = ' [S]earch [D]iagnostics' })
522+ vim .keymap .set (' n' , ' <leader>sr' , smart_telescope_launch (builtin .resume ), { desc = ' [S]earch [R]esume' })
523+ vim .keymap .set (' n' , ' <leader>s.' , smart_telescope_launch (builtin .oldfiles ), { desc = ' [S]earch Recent Files ("." for repeat)' })
524+ vim .keymap .set (' n' , ' <leader><leader>' , smart_telescope_launch (builtin .buffers ), { desc = ' [ ] Find existing buffers' })
525+ -- search files using command shift f
526+ vim .keymap .set (' n' , ' <D-S-f>' , smart_telescope_launch (builtin .live_grep ), { desc = ' Search by [G]rep' })
440527 -- Slightly advanced example of overriding default behavior and theme
441- vim .keymap .set (' n' , ' <leader>/' , function ()
528+ vim .keymap .set (' n' , ' <leader>/' , smart_telescope_launch ( function ()
442529 -- You can pass additional configuration to Telescope to change the theme, layout, etc.
443530 builtin .current_buffer_fuzzy_find (require (' telescope.themes' ).get_dropdown {
444531 winblend = 10 ,
445532 previewer = false ,
446533 })
447- end , { desc = ' [/] Fuzzily search in current buffer' })
534+ end ) , { desc = ' [/] Fuzzily search in current buffer' })
448535
449536 -- It's also possible to pass additional configuration options.
450537 -- See `:help telescope.builtin.live_grep()` for information about particular keys
451- vim .keymap .set (' n' , ' <leader>s/' , function ()
538+ vim .keymap .set (' n' , ' <leader>s/' , smart_telescope_launch ( function ()
452539 builtin .live_grep {
453540 grep_open_files = true ,
454541 prompt_title = ' Live Grep in Open Files' ,
455542 }
456- end , { desc = ' [S]earch [/] in Open Files' })
543+ end ) , { desc = ' [S]earch [/] in Open Files' })
457544
458545 -- Shortcut for searching your Neovim configuration files
459- vim .keymap .set (' n' , ' <leader>sn' , function ()
546+ vim .keymap .set (' n' , ' <leader>sn' , smart_telescope_launch ( function ()
460547 builtin .find_files { cwd = vim .fn .stdpath ' config' }
461- end , { desc = ' [S]earch [N]eovim files' })
548+ end ) , { desc = ' [S]earch [N]eovim files' })
462549 end ,
463550 },
464551
@@ -672,7 +759,7 @@ require('lazy').setup({
672759 -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
673760 local servers = {
674761 -- clangd = {},
675- -- gopls = {},
762+ gopls = {},
676763 -- pyright = {},
677764 -- rust_analyzer = {},
678765 -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@@ -716,6 +803,8 @@ require('lazy').setup({
716803 local ensure_installed = vim .tbl_keys (servers or {})
717804 vim .list_extend (ensure_installed , {
718805 ' stylua' , -- Used to format Lua code
806+ ' prettier' , -- Used to format JSON, JavaScript, etc.
807+ ' goimports' , -- Used to format Go code
719808 })
720809 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
721810
@@ -768,6 +857,9 @@ require('lazy').setup({
768857 end ,
769858 formatters_by_ft = {
770859 lua = { ' stylua' },
860+ json = { ' prettier' },
861+ jsonc = { ' prettier' },
862+ go = { ' goimports' },
771863 -- Conform can also run multiple formatters sequentially
772864 -- python = { "isort", "black" },
773865 --
@@ -835,7 +927,8 @@ require('lazy').setup({
835927 -- <c-k>: Toggle signature help
836928 --
837929 -- See :h blink-cmp-config-keymap for defining your own keymap
838- preset = ' default' ,
930+ preset = ' enter' ,
931+ [' <Tab>' ] = { ' select_and_accept' , ' fallback' },
839932
840933 -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
841934 -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
@@ -876,25 +969,15 @@ require('lazy').setup({
876969 },
877970 },
878971
879- { -- You can easily change to a different colorscheme.
880- -- Change the name of the colorscheme plugin below, and then
881- -- change the command in the config to whatever the name of that colorscheme is.
882- --
883- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
884- ' folke/tokyonight.nvim' ,
885- priority = 1000 , -- Make sure to load this before all the other start plugins.
972+ -- Using Lazy
973+ {
974+ ' navarasu/onedark.nvim' ,
975+ priority = 1000 , -- make sure to load this before all the other start plugins
886976 config = function ()
887- --- @diagnostic disable-next-line : missing-fields
888- require (' tokyonight' ).setup {
889- styles = {
890- comments = { italic = false }, -- Disable italics in comments
891- },
977+ require (' onedark' ).setup {
978+ style = ' darker' ,
892979 }
893-
894- -- Load the colorscheme here.
895- -- Like many other themes, this one has different styles, and you could load
896- -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
897- vim .cmd .colorscheme ' tokyonight-night'
980+ require (' onedark' ).load ()
898981 end ,
899982 },
900983
@@ -919,32 +1002,48 @@ require('lazy').setup({
9191002 -- - sr)' - [S]urround [R]eplace [)] [']
9201003 require (' mini.surround' ).setup ()
9211004
922- -- Simple and easy statusline.
923- -- You could remove this setup call if you don't like it,
924- -- and try some other statusline plugin
925- local statusline = require ' mini.statusline'
926- -- set use_icons to true if you have a Nerd Font
927- statusline .setup { use_icons = vim .g .have_nerd_font }
928-
929- -- You can configure sections in the statusline by overriding their
930- -- default behavior. For example, here we set the section for
931- -- cursor location to LINE:COLUMN
932- --- @diagnostic disable-next-line : duplicate-set-field
933- statusline .section_location = function ()
934- return ' %2l:%-2v'
935- end
936-
9371005 -- ... and there is more!
9381006 -- Check out: https://github.com/echasnovski/mini.nvim
9391007 end ,
9401008 },
1009+
1010+ -- Statusline with git blame
1011+ {
1012+ ' nvim-lualine/lualine.nvim' ,
1013+ dependencies = { ' nvim-tree/nvim-web-devicons' },
1014+ opts = {
1015+ options = {
1016+ icons_enabled = vim .g .have_nerd_font ,
1017+ theme = ' auto' ,
1018+ component_separators = ' |' ,
1019+ section_separators = ' ' ,
1020+ },
1021+ sections = {
1022+ lualine_c = {
1023+ ' filename' ,
1024+ {
1025+ function ()
1026+ local blame = vim .b .gitsigns_blame_line
1027+ if blame then
1028+ return blame
1029+ end
1030+ return ' '
1031+ end ,
1032+ cond = function ()
1033+ return vim .b .gitsigns_blame_line ~= nil
1034+ end ,
1035+ },
1036+ },
1037+ },
1038+ },
1039+ },
9411040 { -- Highlight, edit, and navigate code
9421041 ' nvim-treesitter/nvim-treesitter' ,
9431042 build = ' :TSUpdate' ,
9441043 main = ' nvim-treesitter.configs' , -- Sets main module to use for opts
9451044 -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
9461045 opts = {
947- ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' },
1046+ ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' , ' json ' , ' jsonc ' , ' jinja ' },
9481047 -- Autoinstall languages that are not installed
9491048 auto_install = true ,
9501049 highlight = {
@@ -976,8 +1075,8 @@ require('lazy').setup({
9761075 -- require 'kickstart.plugins.debug',
9771076 -- require 'kickstart.plugins.indent_line',
9781077 -- require 'kickstart.plugins.lint',
979- -- require 'kickstart.plugins.autopairs',
980- -- require 'kickstart.plugins.neo-tree',
1078+ require ' kickstart.plugins.autopairs' ,
1079+ require ' kickstart.plugins.neo-tree' ,
9811080 -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
9821081
9831082 -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
0 commit comments