Skip to content

Commit d5b58a5

Browse files
author
Wilson Soetomo
committed
adding autocomplete
1 parent 3338d39 commit d5b58a5

File tree

5 files changed

+99
-3
lines changed

5 files changed

+99
-3
lines changed

init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,12 @@ rtp:prepend(lazypath)
248248
require('lazy').setup({
249249
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
250250
'NMAC427/guess-indent.nvim', -- Detect tabstop and shiftwidth automatically
251-
252251
-- NOTE: Plugins can also be added by using a table,
253252
-- with the first argument being the link and the following
254253
-- keys can be used to configure plugin behavior/loading/etc.
255254
--
256255
-- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
257256
--
258-
259257
-- Alternatively, use `config = function() ... end` for full control over the configuration.
260258
-- If you prefer to call `setup` explicitly, use:
261259
-- {
@@ -984,7 +982,7 @@ require('lazy').setup({
984982
-- This is the easiest way to modularize your config.
985983
--
986984
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
987-
-- { import = 'custom.plugins' },
985+
{ import = 'custom.plugins' },
988986
--
989987
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
990988
-- Or use telescope!
@@ -1012,5 +1010,7 @@ require('lazy').setup({
10121010
},
10131011
})
10141012

1013+
pcall(require, 'custom.keymaps')
1014+
pcall(require, 'custom.lsp')
10151015
-- The line beneath this is called `modeline`. See `:help modeline`
10161016
-- vim: ts=2 sts=2 sw=2 et

lua/custom/keymaps.lua

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
vim.keymap.set('n', '<C-t>', function()
2+
-- Get the current file's directory (handles unsaved files too)
3+
local cwd = vim.fn.expand '%:p:h'
4+
if cwd == '' then
5+
cwd = vim.fn.getcwd() -- fallback to current working dir
6+
end
7+
8+
-- Open a horizontal split and terminal
9+
vim.cmd 'split'
10+
vim.cmd 'terminal'
11+
vim.cmd 'startinsert'
12+
13+
-- Safely cd into the folder, even if it has spaces
14+
vim.fn.chansend(vim.b.terminal_job_id, 'cd "' .. cwd .. '"\n')
15+
end, { desc = "Open terminal in current file's directory" })
16+
17+
local harpoon = require 'harpoon'
18+
19+
vim.keymap.set('n', '<leader>a', function()
20+
harpoon:list():add()
21+
end, { desc = 'Add file to Harpoon' })
22+
vim.keymap.set('n', '<leader>h', function()
23+
harpoon.ui:toggle_quick_menu(harpoon:list())
24+
end, { desc = 'Toggle Harpoon menu' })
25+
26+
vim.keymap.set('n', '<leader>1', function()
27+
harpoon:list():select(1)
28+
end)
29+
vim.keymap.set('n', '<leader>2', function()
30+
harpoon:list():select(2)
31+
end)
32+
vim.keymap.set('n', '<leader>3', function()
33+
harpoon:list():select(3)
34+
end)
35+
vim.keymap.set('n', '<leader>4', function()
36+
harpoon:list():select(4)
37+
end)

lua/custom/lsp.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
local lspconfig = require 'lspconfig'
2+
local servers = { 'pyright', 'lua_ls' }
3+
4+
for _, server in ipairs(servers) do
5+
lspconfig[server].setup {}
6+
end

lua/custom/plugins/plugins.lua

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
return {
2+
-- Other plugins in here
3+
{
4+
'stevearc/oil.nvim',
5+
opts = {},
6+
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- optional icons
7+
keys = {
8+
{ '<leader>e', '<cmd>Oil<CR>', desc = 'Open file explorer (Oil)' },
9+
},
10+
},
11+
{
12+
'ThePrimeagen/harpoon',
13+
branch = 'harpoon2',
14+
dependencies = { 'nvim-lua/plenary.nvim' },
15+
config = function()
16+
require('harpoon'):setup()
17+
end,
18+
},
19+
{
20+
'hrsh7th/nvim-cmp',
21+
dependencies = {
22+
'hrsh7th/cmp-nvim-lsp',
23+
'hrsh7th/cmp-buffer',
24+
'hrsh7th/cmp-path',
25+
'L3MON4D3/LuaSnip',
26+
'saadparwaiz1/cmp_luasnip',
27+
},
28+
config = function()
29+
local cmp = require 'cmp'
30+
local luasnip = require 'luasnip'
31+
32+
cmp.setup {
33+
snippet = {
34+
expand = function(args)
35+
luasnip.lsp_expand(args.body)
36+
end,
37+
},
38+
mapping = cmp.mapping.preset.insert {
39+
['<Tab>'] = cmp.mapping.select_next_item(),
40+
['<S-Tab>'] = cmp.mapping.select_prev_item(),
41+
['<CR>'] = cmp.mapping.confirm { select = true },
42+
['<C-Space>'] = cmp.mapping.complete(),
43+
},
44+
sources = cmp.config.sources {
45+
{ name = 'nvim_lsp' },
46+
{ name = 'luasnip' },
47+
{ name = 'buffer' },
48+
{ name = 'path' },
49+
},
50+
}
51+
end,
52+
},
53+
}

lua/custom/settings.lua

Whitespace-only changes.

0 commit comments

Comments
 (0)