Skip to content

Commit 9609236

Browse files
committed
feat: add floating terminal and else
1 parent c6d7b15 commit 9609236

File tree

10 files changed

+248
-184
lines changed

10 files changed

+248
-184
lines changed

init.lua

Lines changed: 18 additions & 184 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,11 @@
1-
--[[
2-
3-
=====================================================================
4-
==================== READ THIS BEFORE CONTINUING ====================
5-
=====================================================================
6-
======== .-----. ========
7-
======== .----------------------. | === | ========
8-
======== |.-""""""""""""""""""-.| |-----| ========
9-
======== || || | === | ========
10-
======== || KICKSTART.NVIM || |-----| ========
11-
======== || || | === | ========
12-
======== || || |-----| ========
13-
======== ||:Tutor || |:::::| ========
14-
======== |'-..................-'| |____o| ========
15-
======== `"")----------------(""` ___________ ========
16-
======== /::::::::::| |::::::::::\ \ no mouse \ ========
17-
======== /:::========| |==hjkl==:::\ \ required \ ========
18-
======== '""""""""""""' '""""""""""""' '""""""""""' ========
19-
======== ========
20-
=====================================================================
21-
=====================================================================
22-
23-
What is Kickstart?
24-
25-
Kickstart.nvim is *not* a distribution.
26-
27-
Kickstart.nvim is a starting point for your own configuration.
28-
The goal is that you can read every line of code, top-to-bottom, understand
29-
what your configuration is doing, and modify it to suit your needs.
30-
31-
Once you've done that, you can start exploring, configuring and tinkering to
32-
make Neovim your own! That might mean leaving Kickstart just the way it is for a while
33-
or immediately breaking it into modular pieces. It's up to you!
34-
35-
If you don't know anything about Lua, I recommend taking some time to read through
36-
a guide. One possible example which will only take 10-15 minutes:
37-
- https://learnxinyminutes.com/docs/lua/
38-
39-
After understanding a bit more about Lua, you can use `:help lua-guide` as a
40-
reference for how Neovim integrates Lua.
41-
- :help lua-guide
42-
- (or HTML version): https://neovim.io/doc/user/lua-guide.html
43-
44-
Kickstart Guide:
45-
46-
TODO: The very first thing you should do is to run the command `:Tutor` in Neovim.
47-
48-
If you don't know what this means, type the following:
49-
- <escape key>
50-
- :
51-
- Tutor
52-
- <enter key>
53-
54-
(If you already know the Neovim basics, you can skip this step.)
55-
56-
Once you've completed that, you can continue working through **AND READING** the rest
57-
of the kickstart init.lua.
58-
59-
Next, run AND READ `:help`.
60-
This will open up a help window with some basic information
61-
about reading, navigating and searching the builtin help documentation.
62-
63-
This should be the first place you go to look when you're stuck or confused
64-
with something. It's one of my favorite Neovim features.
65-
66-
MOST IMPORTANTLY, we provide a keymap "<space>sh" to [s]earch the [h]elp documentation,
67-
which is very useful when you're not exactly sure of what you're looking for.
68-
69-
I have left several `:help X` comments throughout the init.lua
70-
These are hints about where to find more information about the relevant settings,
71-
plugins or Neovim features used in Kickstart.
72-
73-
NOTE: Look for lines like this
74-
75-
Throughout the file. These are for you, the reader, to help you understand what is happening.
76-
Feel free to delete them once you know what you're doing, but they should serve as a guide
77-
for when you are first encountering a few different constructs in your Neovim config.
78-
79-
If you experience any errors while trying to install kickstart, run `:checkhealth` for more info.
80-
81-
I hope you enjoy your Neovim journey,
82-
- TJ
83-
84-
P.S. You can delete this when you're done too. It's your config now! :)
85-
--]]
86-
871
-- Set <space> as the leader key
882
-- See `:help mapleader`
893
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
904
vim.g.mapleader = ' '
915
vim.g.maplocalleader = ' '
926

937
-- Set to true if you have a Nerd Font installed and selected in the terminal
94-
vim.g.have_nerd_font = false
8+
vim.g.have_nerd_font = true
959

9610
-- [[ Setting options ]]
9711
-- See `:help vim.o`
@@ -102,7 +16,7 @@ vim.g.have_nerd_font = false
10216
vim.o.number = true
10317
-- You can also add relative line numbers, to help with jumping.
10418
-- Experiment for yourself to see if you like it!
105-
-- vim.o.relativenumber = true
19+
vim.o.relativenumber = true
10620

10721
-- Enable mouse mode, can be useful for resizing splits for example!
10822
vim.o.mouse = 'a'
@@ -120,6 +34,7 @@ end)
12034

12135
-- Enable break indent
12236
vim.o.breakindent = true
37+
vim.o.shiftwidth = 4
12338

12439
-- Save undo history
12540
vim.o.undofile = true
@@ -149,8 +64,8 @@ vim.o.splitbelow = true
14964
-- It is very similar to `vim.o` but offers an interface for conveniently interacting with tables.
15065
-- See `:help lua-options`
15166
-- and `:help lua-options-guide`
152-
vim.o.list = true
153-
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }
67+
vim.o.list = false
68+
-- vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
15469

15570
-- Preview substitutions live, as you type!
15671
vim.o.inccommand = 'split'
@@ -194,17 +109,21 @@ vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }
194109
-- Use CTRL+<hjkl> to switch between windows
195110
--
196111
-- See `:help wincmd` for a list of all window commands
197-
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
198-
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
199-
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
200-
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
201-
112+
-- vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
113+
-- vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
114+
-- vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
115+
-- vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
116+
--
202117
-- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
203118
-- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
204119
-- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
205120
-- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
206121
-- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
207122

123+
-- Navigating quickfix list easier
124+
vim.keymap.set('n', '<C-j>', '<cmd>cnext<CR>', { desc = 'Next item in quickfix list' })
125+
vim.keymap.set('n', '<C-k>', '<cmd>cprev<CR>', { desc = 'Previous item in quickfix list' })
126+
208127
-- [[ Basic Autocommands ]]
209128
-- See `:help lua-guide-autocommands`
210129

@@ -672,7 +591,7 @@ require('lazy').setup({
672591
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
673592
local servers = {
674593
-- clangd = {},
675-
-- gopls = {},
594+
gopls = {},
676595
-- pyright = {},
677596
-- rust_analyzer = {},
678597
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@@ -773,6 +692,7 @@ require('lazy').setup({
773692
--
774693
-- You can use 'stop_after_first' to run the first available formatter from the list
775694
-- javascript = { "prettierd", "prettier", stop_after_first = true },
695+
go = { 'gofumpt' },
776696
},
777697
},
778698
},
@@ -875,94 +795,8 @@ require('lazy').setup({
875795
signature = { enabled = true },
876796
},
877797
},
878-
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.
886-
config = function()
887-
---@diagnostic disable-next-line: missing-fields
888-
require('tokyonight').setup {
889-
styles = {
890-
comments = { italic = false }, -- Disable italics in comments
891-
},
892-
}
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'
898-
end,
899-
},
900-
901-
-- Highlight todo, notes, etc in comments
902-
{ 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } },
903-
904-
{ -- Collection of various small independent plugins/modules
905-
'echasnovski/mini.nvim',
906-
config = function()
907-
-- Better Around/Inside textobjects
908-
--
909-
-- Examples:
910-
-- - va) - [V]isually select [A]round [)]paren
911-
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
912-
-- - ci' - [C]hange [I]nside [']quote
913-
require('mini.ai').setup { n_lines = 500 }
914-
915-
-- Add/delete/replace surroundings (brackets, quotes, etc.)
916-
--
917-
-- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren
918-
-- - sd' - [S]urround [D]elete [']quotes
919-
-- - sr)' - [S]urround [R]eplace [)] [']
920-
require('mini.surround').setup()
921-
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-
937-
-- ... and there is more!
938-
-- Check out: https://github.com/echasnovski/mini.nvim
939-
end,
940-
},
941-
{ -- Highlight, edit, and navigate code
942-
'nvim-treesitter/nvim-treesitter',
943-
build = ':TSUpdate',
944-
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
945-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
946-
opts = {
947-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
948-
-- Autoinstall languages that are not installed
949-
auto_install = true,
950-
highlight = {
951-
enable = true,
952-
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
953-
-- If you are experiencing weird indenting issues, add the language to
954-
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
955-
additional_vim_regex_highlighting = { 'ruby' },
956-
},
957-
indent = { enable = true, disable = { 'ruby' } },
958-
},
959-
-- There are additional nvim-treesitter modules that you can use to interact
960-
-- with nvim-treesitter. You should go explore a few and see what interests you:
961-
--
962-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
963-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
964-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
965-
},
798+
-- import everything under custom/plugins
799+
{ import = 'custom.plugins' },
966800

967801
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
968802
-- init.lua. If you want these files, they are in the repository, so you can just download them and

lazy-lock.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
3+
"blink.cmp": { "branch": "main", "commit": "022521a8910a5543b0251b21c9e1a1e989745796" },
4+
"catppuccin": { "branch": "main", "commit": "fa42eb5e26819ef58884257d5ae95dd0552b9a66" },
5+
"conform.nvim": { "branch": "master", "commit": "0e93e0d12d2f7ebdea9e3e444dfaff0050cefbe6" },
6+
"fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" },
7+
"gitsigns.nvim": { "branch": "main", "commit": "d0f90ef51d4be86b824b012ec52ed715b5622e51" },
8+
"go.nvim": { "branch": "master", "commit": "a3455f48cff718a86275115523dcc735535a13aa" },
9+
"guess-indent.nvim": { "branch": "main", "commit": "84a4987ff36798c2fc1169cbaff67960aed9776f" },
10+
"guihua.lua": { "branch": "master", "commit": "87bea7b98429405caf2a0ce4d029b027bb017c70" },
11+
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
12+
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
13+
"mason-lspconfig.nvim": { "branch": "main", "commit": "bef29b653ba71d442816bf56286c2a686210be04" },
14+
"mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" },
15+
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
16+
"mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" },
17+
"mini.nvim": { "branch": "main", "commit": "35e1767f4cd7dde51256eabae7349a5283a43cba" },
18+
"nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" },
19+
"nvim-lspconfig": { "branch": "master", "commit": "a182334ba933e58240c2c45e6ae2d9c7ae313e00" },
20+
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
21+
"oil.nvim": { "branch": "master", "commit": "08c2bce8b00fd780fb7999dbffdf7cd174e896fb" },
22+
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
23+
"telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" },
24+
"telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" },
25+
"telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" },
26+
"todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" },
27+
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }
28+
}

lua/custom/plugins/colorscheme.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
return {
2+
{
3+
'catppuccin/nvim',
4+
name = 'catppuccin',
5+
priority = 1000,
6+
enabled = true,
7+
config = function()
8+
require('catppuccin').setup {
9+
flavour = 'mocha',
10+
highlight_overrides = {
11+
mocha = function(mocha)
12+
return {
13+
Comment = {
14+
fg = mocha.base,
15+
bg = mocha.overlay0,
16+
},
17+
}
18+
end,
19+
},
20+
}
21+
vim.cmd.colorscheme 'catppuccin'
22+
end,
23+
},
24+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
local state = {
2+
floating = {
3+
buf = -1,
4+
win = -1,
5+
},
6+
}
7+
8+
local function create_floating_window(opts)
9+
opts = opts or {}
10+
local width = opts.width or math.floor(vim.o.columns * 0.8)
11+
local height = opts.height or math.floor(vim.o.lines * 0.8)
12+
13+
-- center the window
14+
local col = math.floor((vim.o.columns - width) / 2)
15+
local row = math.floor((vim.o.lines - height) / 2)
16+
17+
local buf = nil
18+
if vim.api.nvim_buf_is_valid(opts.buf) then
19+
buf = opts.buf
20+
else
21+
buf = vim.api.nvim_create_buf(false, true)
22+
end
23+
24+
local win_config = {
25+
relative = 'editor',
26+
width = width,
27+
height = height,
28+
col = col,
29+
row = row,
30+
style = 'minimal',
31+
border = 'rounded',
32+
}
33+
34+
local win = vim.api.nvim_open_win(buf, true, win_config)
35+
36+
return { buf = buf, win = win }
37+
end
38+
39+
local toggle_terminal = function()
40+
if not vim.api.nvim_win_is_valid(state.floating.win) then
41+
state.floating = create_floating_window { buf = state.floating.buf }
42+
if vim.bo[state.floating.buf].buftype ~= 'terminal' then
43+
vim.cmd.terminal()
44+
end
45+
else
46+
vim.api.nvim_win_hide(state.floating.win)
47+
end
48+
vim.cmd 'startinsert!'
49+
end
50+
51+
vim.api.nvim_create_user_command('Floaterminal', toggle_terminal, {})
52+
53+
vim.keymap.set({ 'n', 't' }, '<leader>tt', '<cmd>Floaterminal<CR>', { desc = '[T]oggle floating [T]erminal' })

0 commit comments

Comments
 (0)