adding autocomplete

This commit is contained in:
Wilson Soetomo 2025-07-28 15:03:20 -04:00
parent 3338d39206
commit d5b58a58b0
5 changed files with 99 additions and 3 deletions

37
lua/custom/keymaps.lua Normal file
View file

@ -0,0 +1,37 @@
vim.keymap.set('n', '<C-t>', function()
-- Get the current file's directory (handles unsaved files too)
local cwd = vim.fn.expand '%:p:h'
if cwd == '' then
cwd = vim.fn.getcwd() -- fallback to current working dir
end
-- Open a horizontal split and terminal
vim.cmd 'split'
vim.cmd 'terminal'
vim.cmd 'startinsert'
-- Safely cd into the folder, even if it has spaces
vim.fn.chansend(vim.b.terminal_job_id, 'cd "' .. cwd .. '"\n')
end, { desc = "Open terminal in current file's directory" })
local harpoon = require 'harpoon'
vim.keymap.set('n', '<leader>a', function()
harpoon:list():add()
end, { desc = 'Add file to Harpoon' })
vim.keymap.set('n', '<leader>h', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end, { desc = 'Toggle Harpoon menu' })
vim.keymap.set('n', '<leader>1', function()
harpoon:list():select(1)
end)
vim.keymap.set('n', '<leader>2', function()
harpoon:list():select(2)
end)
vim.keymap.set('n', '<leader>3', function()
harpoon:list():select(3)
end)
vim.keymap.set('n', '<leader>4', function()
harpoon:list():select(4)
end)

6
lua/custom/lsp.lua Normal file
View file

@ -0,0 +1,6 @@
local lspconfig = require 'lspconfig'
local servers = { 'pyright', 'lua_ls' }
for _, server in ipairs(servers) do
lspconfig[server].setup {}
end

View file

@ -0,0 +1,53 @@
return {
-- Other plugins in here
{
'stevearc/oil.nvim',
opts = {},
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- optional icons
keys = {
{ '<leader>e', '<cmd>Oil<CR>', desc = 'Open file explorer (Oil)' },
},
},
{
'ThePrimeagen/harpoon',
branch = 'harpoon2',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
require('harpoon'):setup()
end,
},
{
'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'L3MON4D3/LuaSnip',
'saadparwaiz1/cmp_luasnip',
},
config = function()
local cmp = require 'cmp'
local luasnip = require 'luasnip'
cmp.setup {
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert {
['<Tab>'] = cmp.mapping.select_next_item(),
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<CR>'] = cmp.mapping.confirm { select = true },
['<C-Space>'] = cmp.mapping.complete(),
},
sources = cmp.config.sources {
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
},
}
end,
},
}

0
lua/custom/settings.lua Normal file
View file