1
Fork 0

Add lsp and stuff

This commit is contained in:
Hadeed 2023-08-30 04:41:29 +05:00
parent d4c71cbd0d
commit 5b02501e0f
5 changed files with 85 additions and 38 deletions

View file

@ -1,3 +1,42 @@
local M = {}
function M.telescope()
local telescope = require("telescope")
local builtin = require("telescope.builtin")
vim.keymap.set("", "<leader>ff", builtin.find_files)
vim.keymap.set("", "<leader>fh", builtin.help_tags)
vim.keymap.set("", "<leader>ft", builtin.builtin)
vim.keymap.set("", "<leader>fm", builtin.man_pages)
vim.keymap.set("", "<leader>fb", telescope.extensions.file_browser.file_browser)
vim.keymap.set("", "<leader>fd", function() builtin.find_files({
cwd = "$DOTS",
prompt_title = "< Dotfiles >"
}) end)
end
function M.harpoon()
vim.keymap.set("", "<leader>ha", require("harpoon.mark").add_file)
vim.keymap.set("", "<leader>ho", require("harpoon.ui").toggle_quick_menu)
vim.keymap.set("", "<leader>hn", function() require("harpoon.ui").nav_file(1) end)
vim.keymap.set("", "<leader>hk", function() require("harpoon.ui").nav_file(2) end)
vim.keymap.set("", "<leader>hi", function() require("harpoon.ui").nav_file(3) end)
end
function M.lsp(env)
local opts = { buffer = env.buffer }
vim.keymap.set("", "<leader>en", vim.diagnostic.goto_next, opts)
vim.keymap.set("", "<leader>ep", vim.diagnostic.goto_prev, opts)
vim.keymap.set("", "<leader>ee", vim.diagnostic.open_float, opts)
end
------------------------------------------------------------------------------
-- Not plugin related --
------------------------------------------------------------------------------
local function swap(a, b)
vim.keymap.set("", a, b)
vim.keymap.set("", b, a)
@ -6,26 +45,33 @@ end
swap(";", ":")
swap("'", "`")
vim.keymap.set("", "<leader>q", "<CMD>conf q<CR>")
vim.keymap.set("", "<leader>w", "<CMD>w<CR>")
vim.keymap.set("", "<leader>x", "<CMD>x<CR>")
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "n", "nzz")
vim.keymap.set("n", "N", "Nzz")
vim.keymap.set("n", "<C-U>", "<C-U>zz")
vim.keymap.set("n", "<C-D>", "<C-D>zz")
vim.keymap.set("n", "<C-N>", "<CMD>nohls<CR>")
vim.keymap.set("n", "<leader>w", "<C-W>")
vim.keymap.set("", "<leader>w", "<C-W>")
local function window_map(key, mapping)
local k = '<M-'..key..'>'
local m = '<CMD>wincmd ' .. (mapping or key) .. '<CR>'
vim.keymap.set({'n', 'i', 't'}, k, m)
vim.keymap.set({"", "i", "t"}, k, m)
end
window_map("h")
window_map("j")
window_map("k")
window_map("l")
vim.keymap.set("", "<leader>q", "<CMD>confirm quit<CR>")
vim.keymap.set("", "<leader>x", "<CMD>exit<CR>")
vim.keymap.set("", "<leader><leader>x", "<CMD>write<BAR>source %<CR>")
vim.keymap.set("", "n", "nzz")
vim.keymap.set("", "N", "Nzz")
vim.keymap.set("", "<C-N>", "<CMD>nohls<CR>")
vim.keymap.set("", "<C-U>", "<C-U>zz")
vim.keymap.set("", "<C-D>", "<C-D>zz")
vim.keymap.set("i", "jk", "<ESC>")
vim.keymap.set("i", "kj", "<ESC>")
return M

View file

@ -14,6 +14,13 @@ return {
end
},
{
"ThePrimeagen/harpoon",
config = function()
require("keymaps").harpoon()
end
},
{ "abecodes/tabout.nvim", dependencies = { "nvim-treesitter" }, config = true },
{ "numToStr/Comment.nvim", config = true },
@ -21,6 +28,5 @@ return {
{ "windwp/nvim-autopairs", config = true },
"fladson/vim-kitty",
"tpope/vim-unimpaired",
"neovim/nvim-lspconfig"
"tpope/vim-unimpaired"
}

16
nvim/lua/plugins/lsp.lua Normal file
View file

@ -0,0 +1,16 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
"nvim-telescope/telescope.nvim"
},
config = function()
local lspconfig = require("lspconfig")
lspconfig.ccls.setup {}
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = require("keymaps").lsp
})
end
}

View file

@ -8,7 +8,6 @@ return {
},
config = function()
local telescope = require("telescope")
local fb_actions = require("telescope").extensions.file_browser.actions
telescope.setup({
pickers = {
@ -19,20 +18,11 @@ return {
extensions = {
file_browser = {
grouped = true,
hide_parent_dir = true,
hijack_netrw = true,
initial_mode = "normal",
hidden = true,
respect_gitignore = false,
sorting_strategy = "ascending",
layout_config = {
prompt_position = "top"
},
mappings = {
n = {
["h"] = fb_actions.goto_parent_dir,
["l"] = "select_default",
["g"] = fb_actions.toggle_hidden
}
}
}
}
@ -41,16 +31,7 @@ return {
telescope.load_extension("file_browser")
telescope.load_extension("fzf")
local builtin = require("telescope.builtin")
vim.keymap.set("", "<leader>tf", builtin.find_files)
vim.keymap.set("", "<leader>th", builtin.help_tags)
vim.keymap.set("", "<leader>tr", builtin.buffers)
vim.keymap.set("", "<leader>ts", telescope.extensions.file_browser.file_browser)
vim.keymap.set("", "<leader>tt", builtin.builtin)
require("keymaps").telescope()
vim.keymap.set("", "<leader>tc", function() builtin.find_files({
cwd = "$DOTS",
prompt_title = "< Dotfiles >"
}) end)
end,
end
}

View file

@ -2,8 +2,6 @@ alias p='sudo pacman -S'
alias pu='sudo pacman -Syu'
alias vi='nvim'
alias vif='nvim +"norm 1 tf" +startinsert'
alias vic='nvim +"norm 1 tc" +startinsert'
alias l='exa -x --group-directories-first --icons'
alias ll='l -lbh --git --no-time'