feat: add sensible copilot accept and term

main
jaredgoldman 2024-04-07 17:09:45 -04:00
parent 94bf4f62c1
commit 75abeb74f7
8 changed files with 61 additions and 41 deletions

View File

@ -10,3 +10,4 @@ require("config.comment")
require("config.themery") require("config.themery")
require("config.theme") require("config.theme")
require("config.lualine") require("config.lualine")
require("config.fterm")

View File

@ -1,14 +1,15 @@
{ {
"FTerm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" },
"LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" },
"catppuccin": { "branch": "main", "commit": "aebe43db9cb26e1c70fc5b2fd4158169c405e720" }, "catppuccin": { "branch": "main", "commit": "aebe43db9cb26e1c70fc5b2fd4158169c405e720" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"lazy.nvim": { "branch": "main", "commit": "bef521ac89c8d423f9d092e37b58e8af0c099309" }, "lazy.nvim": { "branch": "main", "commit": "31ddbea7c10b6920c9077b66c97951ca8682d5c8" },
"lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "9dfcf2036c223920826140f0151d929a43f9eceb" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "44509689b9bf3984d729cc264aacb31cb7f41668" },
"mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" }, "mason.nvim": { "branch": "main", "commit": "751b1fcbf3d3b783fcf8d48865264a9bcd8f9b10" },
"monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" }, "monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" },
"nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" }, "nvim-cmp": { "branch": "main", "commit": "ce16de5665c766f39c271705b17fff06f7bcb84f" },

View File

@ -0,0 +1,3 @@
require("FTerm").setup({
blend = 25
})

View File

@ -1,9 +1,22 @@
local fterm = require('FTerm')
local keymap = vim.api.nvim_set_keymap local keymap = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
local api = vim.api
-- Custom commands
api.nvim_create_user_command('FTermToggle', fterm.toggle, { bang = true })
api.nvim_create_user_command('FTermClose', fterm.close, { bang = true })
local mappings = { local mappings = {
n = { n = {
-- highlighting
["<leader>nh"] = ":nohl<CR>", ["<leader>nh"] = ":nohl<CR>",
-- move between buffers
["<c-h>"] = "<C-w>h",
["<c-j>"] = "<C-w>j",
["<c-k>"] = "<C-w>k",
["<c-l>"] = "<C-w>l",
-- open and close buggers
["<leader>sv"] = "<C-w>s", ["<leader>sv"] = "<C-w>s",
["<leader>sh"] = "<C-w>v", ["<leader>sh"] = "<C-w>v",
["<leader>se"] = "<C-w>=", ["<leader>se"] = "<C-w>=",
@ -11,39 +24,45 @@ local mappings = {
-- nvim-tree -- nvim-tree
["<leader>e"] = ":NvimTreeToggle<CR>", ["<leader>e"] = ":NvimTreeToggle<CR>",
["<leader>cf"] = ":NvimTreeCollapse<CR>", ["<leader>cf"] = ":NvimTreeCollapse<CR>",
-- lsp -- LSP
["<leader>ls"] = ":lspstop<CR>", ["<leader>ls"] = ":lspstop<CR>",
["<leader>lo"] = ":lspstart<CR>", ["<leader>lo"] = ":lspstart<CR>",
-- move between buffers -- Telescope
["<c-h>"] = "<C-w>h",
["<c-j>"] = "<C-w>j",
["<c-k>"] = "<C-w>k",
["<c-l>"] = "<C-w>l",
["<leader>ff"] = "<cmd>Telescope find_files<CR>", ["<leader>ff"] = "<cmd>Telescope find_files<CR>",
["<leader>fw"] = "<cmd>Telescope live_grep<CR>", ["<leader>fw"] = "<cmd>Telescope live_grep<CR>",
["<leader>fc"] = "<cmd>Telescope grep_string<CR>", ["<leader>fc"] = "<cmd>Telescope grep_string<CR>",
["<leader>th"] = "<cmd>Themery<CR>", ["<leader>th"] = "<cmd>Themery<CR>",
["<leader>sm"] = ":MaximizerToggle<CR>" ["<leader>sm"] = ":MaximizerToggle<CR>",
-- FTerm
["<leader>h"] = "<cmd>FTermToggle<CR>"
}, },
x = { x = {
["J"] = ":move '>+1<CR>gv-gv",
["K"] = ":move '<-2<CR>gv-gv",
["<A-j>"] = ":move '>+1<CR>gv-gv", ["<A-j>"] = ":move '>+1<CR>gv-gv",
["<A-k>"] = ":move '<-2<CR>gv-gv", ["<A-k>"] = ":move '<-2<CR>gv-gv",
}, },
i = { i = {
["c-j"] = [[<cmd>lua require('copilot').accept()<CR>]], ["<C-Space>"] = { 'copilot#Accept("<CR>")', expr = true },
["<m-l>"] = "<esc>", ["<A-l>"] = "<esc>",
}, },
t = {
["A-l"] = "<cmd>FTermClose<CR>"
}
} }
for mode, mode_mappings in pairs(mappings) do for mode, mode_mappings in pairs(mappings) do
for key, mapping in pairs(mode_mappings) do for key, mapping in pairs(mode_mappings) do
if type(mapping) == "function" then if type(mapping) == "function" then
keymap(mode, key, "<cmd>lua " .. mapping() .. "<>", opts) -- For direct Lua function calls; ensure your function returns a string command
keymap(mode, key, "<cmd>lua " .. mapping() .. "<CR>", opts)
elseif type(mapping) == "table" and mapping.expr then
-- For expression mappings, like for copilot
local expr_opts = vim.tbl_extend("force", opts, { expr = true })
keymap(mode, key, mapping[1], expr_opts)
elseif type(mapping) == "table" then elseif type(mapping) == "table" then
-- For mappings that have their options specified directly
keymap(mode, key, mapping[1], mapping[2] or opts) keymap(mode, key, mapping[1], mapping[2] or opts)
else else
-- For simple string command mappings
keymap(mode, key, mapping, opts) keymap(mode, key, mapping, opts)
end end
end end

View File

@ -1,14 +1,5 @@
-- Set different settings for different languages' LSP
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
-- - the settings table is sent to the LSP
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
-- Customized on_attach function
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true }
local mappings = { local mappings = {
['<leader>k'] = vim.diagnostic.open_float, ['<leader>k'] = vim.diagnostic.open_float,
['[d'] = vim.diagnostic.goto_prev, ['[d'] = vim.diagnostic.goto_prev,

View File

@ -5,7 +5,7 @@ local global = vim.g
-- Hint: use `:h <option>` to figure out the meaning if needed -- Hint: use `:h <option>` to figure out the meaning if needed
opt.clipboard = "unnamedplus" -- use system clipboard opt.clipboard = "unnamedplus" -- use system clipboard
opt.completeopt = { "menu", "menuone", "noselect" } opt.completeopt = { "menu", "menuone", "noselect" }
opt.mouse = "a" -- allow the mouse to be used in Nvim opt.mouse = "a" -- allow the mouse to be used in Nvim
-- General -- General
opt.wrap = false opt.wrap = false
@ -18,31 +18,33 @@ opt.cursorline = true
opt.backspace = "indent,eol,start" opt.backspace = "indent,eol,start"
-- Tab -- Tab
opt.tabstop = 4 -- number of visual spaces per TAB opt.tabstop = 4 -- number of visual spaces per TAB
opt.softtabstop = 4 -- number of spacesin tab when editing opt.softtabstop = 4 -- number of spacesin tab when editing
opt.shiftwidth = 4 -- insert 4 spaces on a tab opt.shiftwidth = 4 -- insert 4 spaces on a tab
opt.expandtab = true -- tabs are spaces, mainly because of python opt.expandtab = true -- tabs are spaces, mainly because of python
-- UI config -- UI config
opt.number = true -- show absolute number opt.number = true -- show absolute number
-- opt.relativenumber = true -- add numbers to each line on the left side -- opt.relativenumber = true -- add numbers to each line on the left side
opt.cursorline = true -- highlight cursor line underneath the cursor horizontally opt.cursorline = true -- highlight cursor line underneath the cursor horizontally
opt.splitbelow = true -- open new vertical split bottom opt.splitbelow = true -- open new vertical split bottom
opt.splitright = true -- open new horizontal splits right opt.splitright = true -- open new horizontal splits right
opt.termguicolors = true -- enabl 24-bit RGB color in the TUI opt.termguicolors = true -- enabl 24-bit RGB color in the TUI
-- Searching -- Searching
opt.incsearch = true -- search as characters are entered opt.incsearch = true -- search as characters are entered
opt.hlsearch = false -- do not highlight matches opt.hlsearch = false -- do not highlight matches
opt.ignorecase = true -- ignore case in searches by default opt.ignorecase = true -- ignore case in searches by default
opt.smartcase = true -- but make it case sensitive if an uppercase is entered opt.smartcase = true -- but make it case sensitive if an uppercase is entered
-- Show trailing whitespace -- History
opt.undofile = true
opt.undodir = os.getenv("HOME") .. "/.local/share/nvim/undo"
-- Whitespace
api.nvim_set_option("list", true) api.nvim_set_option("list", true)
api.nvim_set_option("listchars", "eol:$,nbsp:_,tab:>-,trail:~,extends:>,precedes:<") api.nvim_set_option("listchars", "eol:$,nbsp:_,tab:>-,trail:~,extends:>,precedes:<")
-- Remove whitespace on save
api.nvim_create_autocmd({ "BufWritePre" }, { api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" }, pattern = { "*" },
command = [[if &filetype !~# 'lsp' | %s/\s\+$//e | endif]], command = [[if &filetype !~# 'lsp' | %s/\s\+$//e | endif]],
}) })

View File

@ -56,5 +56,7 @@ require("lazy").setup({
{ {
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' } dependencies = { 'nvim-tree/nvim-web-devicons' }
} },
'numToStr/FTerm.nvim',
'github/copilot.vim'
}) })

View File

@ -3,6 +3,7 @@
- lsp with mason x - lsp with mason x
- telescope x - telescope x
- theming x - theming x
- tabfluline - tabfluline x
- terminal
- harpoon - harpoon
- extended history - extended history