aboutsummaryrefslogtreecommitdiff
path: root/lua/pml68
diff options
context:
space:
mode:
authorpml68 <tutorialmester@gmail.com>2024-03-18 21:33:54 +0100
committerpml68 <tutorialmester@gmail.com>2024-03-18 21:33:54 +0100
commit30073d82a57a4839f9687c9dbcde627c112b1839 (patch)
treeefe4ff05512462fc94edeea7c1f5996149cfa96c /lua/pml68
parentfeat: missed the Float part (diff)
downloadnvim-30073d82a57a4839f9687c9dbcde627c112b1839.tar.gz
feat: autocompletion, keymaps and more
Diffstat (limited to 'lua/pml68')
-rw-r--r--lua/pml68/configs/cmp.lua21
-rw-r--r--lua/pml68/configs/lspconfig.lua1
-rw-r--r--lua/pml68/configs/settings/lua_ls.lua24
-rw-r--r--lua/pml68/configs/toggleterm.lua15
-rw-r--r--lua/pml68/init.lua6
-rw-r--r--lua/pml68/plugins.lua89
-rw-r--r--lua/pml68/remap.lua37
7 files changed, 155 insertions, 38 deletions
diff --git a/lua/pml68/configs/cmp.lua b/lua/pml68/configs/cmp.lua
new file mode 100644
index 0000000..ff69651
--- /dev/null
+++ b/lua/pml68/configs/cmp.lua
@@ -0,0 +1,21 @@
+local cmp = require("cmp")
+
+cmp.setup({
+ sources = {
+ {name = 'nvim_lsp'},
+ },
+ preselect = 'item',
+ completion = {
+ completeopt = 'menu,menuone,noinsert'
+ },
+ mapping = cmp.mapping.preset.insert({
+ ['<CR>'] = cmp.mapping.confirm({select = false}),
+ ['<S-Tab>'] = cmp.mapping.select_prev_item({behavior = 'select'}),
+ ['<Tab>'] = cmp.mapping.select_next_item({behavior = 'select'}),
+ }),
+ snippet = {
+ expand = function(args)
+ require('luasnip').lsp_expand(args.body)
+ end,
+ },
+})
diff --git a/lua/pml68/configs/lspconfig.lua b/lua/pml68/configs/lspconfig.lua
index 12aacf8..40badc3 100644
--- a/lua/pml68/configs/lspconfig.lua
+++ b/lua/pml68/configs/lspconfig.lua
@@ -1,5 +1,4 @@
local capabilities = require("cmp_nvim_lsp").default_capabilities()
-
local lspconfig = require("lspconfig")
local servers = {
diff --git a/lua/pml68/configs/settings/lua_ls.lua b/lua/pml68/configs/settings/lua_ls.lua
index 7db368c..de4124c 100644
--- a/lua/pml68/configs/settings/lua_ls.lua
+++ b/lua/pml68/configs/settings/lua_ls.lua
@@ -2,18 +2,18 @@ return {
settings = {
Lua = {
diagnostics = {
- globals = { "vim " },
- },
- workspace = {
- library = {
- [vim.fn.expand "$VIMRUNTIME/lua"] = true,
- [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
- [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true,
- [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
- },
- maxPreload = 100000,
- preloadFileSize = 10000,
- }
+ globals = { "vim " },
+ },
+ workspace = {
+ library = {
+ [vim.fn.expand "$VIMRUNTIME/lua"] = true,
+ [vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
+ [vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types"] = true,
+ [vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
+ },
+ maxPreload = 100000,
+ preloadFileSize = 10000,
+ }
}
}
}
diff --git a/lua/pml68/configs/toggleterm.lua b/lua/pml68/configs/toggleterm.lua
new file mode 100644
index 0000000..6bf4f14
--- /dev/null
+++ b/lua/pml68/configs/toggleterm.lua
@@ -0,0 +1,15 @@
+local Terminal = require('toggleterm.terminal').Terminal
+local lazygit = Terminal:new({
+ cmd = "lazygit",
+ hidden = true,
+ direction = "float",
+ float_opts = {
+ border = "double",
+ },
+})
+
+function _lazygit_toggle()
+ lazygit:toggle()
+end
+
+vim.keymap.set("n", "<leader>g", "<cmd> lua _lazygit_toggle() <CR>", {noremap = true, silent = true})
diff --git a/lua/pml68/init.lua b/lua/pml68/init.lua
index de513c3..e8b5665 100644
--- a/lua/pml68/init.lua
+++ b/lua/pml68/init.lua
@@ -5,6 +5,10 @@ vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
vim.opt.relativenumber = true
-vim.cmd("set nu")
+vim.opt.nu = true
+vim.opt.shiftwidth = 2
+vim.opt.tabstop = 2
vim.opt.clipboard = "unnamedplus"
+
+vim.opt.termguicolors = true
diff --git a/lua/pml68/plugins.lua b/lua/pml68/plugins.lua
index 9a4b0e8..215d65d 100644
--- a/lua/pml68/plugins.lua
+++ b/lua/pml68/plugins.lua
@@ -1,14 +1,52 @@
local plugins = {
-- CMP
- {
+ {
"hrsh7th/nvim-cmp",
- dependencies = {
+ event = "InsertEnter",
+ dependencies = {
+ {
+ "L3MON4D3/LuaSnip",
+ dependencies = "rafamadriz/friendly-snippets",
+ },
+ {
+ "windwp/nvim-autopairs",
+ opts = {
+ fast_wrap = {},
+ disable_filetype = { "TelescopePrompt", "vim" },
+ },
+ config = function(_, opts)
+ require("nvim-autopairs").setup(opts)
+
+ local cmp_autopairs = require "nvim-autopairs.completion.cmp"
+ require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
+ end,
+ },
"hrsh7th/cmp-nvim-lsp",
- "hrsh7th/cmp-buffer",
- "hrsh7th/cmp-path",
- "hrsh7th/cmp-cmdline",
- }
+ },
+ config = function()
+ require("pml68.configs.cmp")
+ end,
},
+ -- Terminal
+ {
+ "akinsho/toggleterm.nvim",
+ version = "*",
+ opts = {
+ shade_terminals = false,
+ persist_size = false,
+ size = function(term)
+ if term.direction == "horizontal" then
+ return 15
+ elseif term.direction == "vertical" then
+ return vim.o.columns * 0.4
+ end
+ end,
+ },
+ config = function(_, opts)
+ require("pml68.configs.toggleterm")
+ require("toggleterm").setup(opts)
+ end
+ },
-- Undotree
{
"mbbill/undotree",
@@ -23,25 +61,25 @@ local plugins = {
"lewis6991/gitsigns.nvim",
event = "BufReadPre",
opts = {
- signs = {
- add = { text = "│" },
- change = { text = "│" },
- delete = { text = "󰍵" },
- topdelete = { text = "‾" },
- changedelete = { text = "~" },
- untracked = { text = "│" },
+ signs = {
+ add = { text = "│" },
+ change = { text = "│" },
+ delete = { text = "󰍵" },
+ topdelete = { text = "‾" },
+ changedelete = { text = "~" },
+ untracked = { text = "│" },
},
- on_attach = function(bufnr)
- local gs = package.loaded.gitsigns
+ on_attach = function(bufnr)
+ local gs = package.loaded.gitsigns
- local function map(mode, l, r, opts)
- opts = opts or {}
- opts.buffer = bufnr
- vim.keymap.set(mode, l, r, opts)
- end
+ local function map(mode, l, r, opts)
+ opts = opts or {}
+ opts.buffer = bufnr
+ vim.keymap.set(mode, l, r, opts)
+ end
- map("n", "<leader>gb", gs.blame_line)
- end,
+ map("n", "<leader>gb", gs.blame_line)
+ end,
},
config = function(_, opts)
require("gitsigns").setup(opts)
@@ -182,13 +220,16 @@ local plugins = {
"mfussenegger/nvim-dap",
},
opts = {
- handlers = {},
+ handlers = {},
},
},
{
"rcarriga/nvim-dap-ui",
event = "VeryLazy",
- dependencies = "mfussenegger/nvim-dap",
+ dependencies = {
+ "mfussenegger/nvim-dap",
+ "nvim-neotest/nvim-nio"
+ },
config = function()
local dap = require("dap")
local dapui = require("dapui")
diff --git a/lua/pml68/remap.lua b/lua/pml68/remap.lua
index 578cb6f..dab15ca 100644
--- a/lua/pml68/remap.lua
+++ b/lua/pml68/remap.lua
@@ -5,6 +5,7 @@ vim.keymap.set("v", "<leader>cs", "<cmd> Silicon <CR>")
vim.keymap.set("n", "<leader>cp", ":!xclip -sel clip -target image/png -i 2024*.png && rm 2024*.png <CR>")
vim.keymap.set("n", "<leader>u", "<cmd>UndotreeToggle<CR>")
+-- keyboard problems (temporary)
function starting()
local pos = vim.api.nvim_win_get_cursor(0)[2]
local line = vim.api.nvim_get_current_line()
@@ -13,3 +14,39 @@ function starting()
end
vim.keymap.set("n", "<leader>s", "<cmd> lua starting() <CR>")
+
+-- switch between windows
+vim.keymap.set("n", "<C-h>", "<C-w>h")
+vim.keymap.set("n", "<C-l>", "<C-w>l")
+vim.keymap.set("n", "<C-j>", "<C-w>j")
+vim.keymap.set("n", "<C-k>", "<C-w>k")
+
+-- close current buffer
+vim.keymap.set("n", "<leader>x", "<cmd> bd <CR>")
+
+-- termtoggle
+vim.keymap.set("n", "<leader>h", "<cmd> ToggleTerm direction=horizontal <CR>")
+vim.keymap.set("n", "<leader>v", "<cmd> ToggleTerm direction=vertical <CR>")
+
+-- Diagnostics, LSP
+vim.keymap.set('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
+vim.keymap.set('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
+vim.keymap.set('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
+
+vim.api.nvim_create_autocmd('LspAttach', {
+ desc = 'LSP actions',
+ callback = function(event)
+ local opts = {buffer = event.buf}
+
+ vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
+ vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
+ vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
+ vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
+ vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
+ vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
+ vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
+ vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
+ vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
+ vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
+ end
+})