feat: add sensible copilot accept and term
parent
94bf4f62c1
commit
75abeb74f7
1
init.lua
1
init.lua
|
@ -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")
|
||||||
|
|
|
@ -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" },
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
require("FTerm").setup({
|
||||||
|
blend = 25
|
||||||
|
})
|
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -37,11 +37,13 @@ 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]],
|
||||||
|
|
|
@ -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'
|
||||||
})
|
})
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue