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) local function swap(a, b)
vim.keymap.set("", a, b) vim.keymap.set("", a, b)
vim.keymap.set("", b, a) vim.keymap.set("", b, a)
@ -6,26 +45,33 @@ end
swap(";", ":") swap(";", ":")
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("", "<leader>w", "<C-W>")
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>")
local function window_map(key, mapping) local function window_map(key, mapping)
local k = '<M-'..key..'>' local k = '<M-'..key..'>'
local m = '<CMD>wincmd ' .. (mapping or key) .. '<CR>' local m = '<CMD>wincmd ' .. (mapping or key) .. '<CR>'
vim.keymap.set({'n', 'i', 't'}, k, m) vim.keymap.set({"", "i", "t"}, k, m)
end end
window_map("h") window_map("h")
window_map("j") window_map("j")
window_map("k") window_map("k")
window_map("l") 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 end
}, },
{
"ThePrimeagen/harpoon",
config = function()
require("keymaps").harpoon()
end
},
{ "abecodes/tabout.nvim", dependencies = { "nvim-treesitter" }, config = true }, { "abecodes/tabout.nvim", dependencies = { "nvim-treesitter" }, config = true },
{ "numToStr/Comment.nvim", config = true }, { "numToStr/Comment.nvim", config = true },
@ -21,6 +28,5 @@ return {
{ "windwp/nvim-autopairs", config = true }, { "windwp/nvim-autopairs", config = true },
"fladson/vim-kitty", "fladson/vim-kitty",
"tpope/vim-unimpaired", "tpope/vim-unimpaired"
"neovim/nvim-lspconfig"
} }

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() config = function()
local telescope = require("telescope") local telescope = require("telescope")
local fb_actions = require("telescope").extensions.file_browser.actions
telescope.setup({ telescope.setup({
pickers = { pickers = {
@ -19,20 +18,11 @@ return {
extensions = { extensions = {
file_browser = { file_browser = {
grouped = true, grouped = true,
hide_parent_dir = true, hidden = true,
hijack_netrw = true,
initial_mode = "normal",
respect_gitignore = false, respect_gitignore = false,
sorting_strategy = "ascending", sorting_strategy = "ascending",
layout_config = { layout_config = {
prompt_position = "top" 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("file_browser")
telescope.load_extension("fzf") telescope.load_extension("fzf")
local builtin = require("telescope.builtin") require("keymaps").telescope()
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)
vim.keymap.set("", "<leader>tc", function() builtin.find_files({ end
cwd = "$DOTS",
prompt_title = "< Dotfiles >"
}) end)
end,
} }

View file

@ -2,8 +2,6 @@ alias p='sudo pacman -S'
alias pu='sudo pacman -Syu' alias pu='sudo pacman -Syu'
alias vi='nvim' 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 l='exa -x --group-directories-first --icons'
alias ll='l -lbh --git --no-time' alias ll='l -lbh --git --no-time'