mirror of
https://github.com/hyzendust/KickestEnd.nvim.git
synced 2026-02-15 02:21:14 +01:00
Modified Custom Keybind to ask for a filename if the current buffer is new and unsaved. Fixed a mason bug
This commit is contained in:
59
init.lua
59
init.lua
@@ -28,7 +28,6 @@ vim.opt.rtp:prepend(lazypath)
|
||||
-- [[ Configure plugins ]]
|
||||
-- NOTE: Here is where you install your plugins.
|
||||
-- You can configure plugins using the `config` key.
|
||||
--
|
||||
-- You can also configure plugins after the setup call,
|
||||
-- as they will be available in your neovim runtime.
|
||||
require('lazy').setup({
|
||||
@@ -300,13 +299,41 @@ vim.keymap.set('n', '<leader>n', '<Cmd>cd %:p:h | Neotree toggle float<CR>')
|
||||
vim.keymap.set('n', '<leader>t', '<Cmd>tabnew +term<CR>i')
|
||||
|
||||
--Close current window
|
||||
vim.keymap.set('n', '<Tab>q', '<Cmd>q<CR>')
|
||||
vim.keymap.set('n', '<leader>q', '<Cmd>q<CR>')
|
||||
|
||||
-- Save current buffer (asks for filename if new/unsaved)
|
||||
vim.keymap.set('n', '<leader>w', function()
|
||||
if vim.api.nvim_buf_get_name(0) == "" then
|
||||
-- Ask user for a filename
|
||||
local filename = vim.fn.input("Save as: ", "", "file")
|
||||
if filename ~= "" then
|
||||
vim.cmd("saveas " .. vim.fn.fnameescape(filename))
|
||||
else
|
||||
print("Save cancelled")
|
||||
end
|
||||
else
|
||||
vim.cmd("w")
|
||||
end
|
||||
end, { desc = "Save buffer (prompt if new file)" })
|
||||
|
||||
--Discard changes and Close current window
|
||||
vim.keymap.set('n', '<leader>qq', '<Cmd>q!<CR>')
|
||||
vim.keymap.set('n', '<leader>qn', '<Cmd>q!<CR>')
|
||||
|
||||
--Save current buffer
|
||||
vim.keymap.set('n', '<Tab>w', '<Cmd>w<CR>')
|
||||
-- Save changes and close current window (asks for filename if new/unsaved)
|
||||
vim.keymap.set('n', '<leader>qy', function()
|
||||
if vim.api.nvim_buf_get_name(0) == "" then
|
||||
-- Ask user for a filename
|
||||
local filename = vim.fn.input("Save as: ", "", "file")
|
||||
if filename ~= "" then
|
||||
vim.cmd("saveas " .. vim.fn.fnameescape(filename))
|
||||
vim.cmd("q")
|
||||
else
|
||||
print("Save cancelled")
|
||||
end
|
||||
else
|
||||
vim.cmd("wq")
|
||||
end
|
||||
end, { desc = "Save & quit (prompt if new file)" })
|
||||
|
||||
--Switch below/right split windows
|
||||
vim.keymap.set('n', '<leader><Tab>', '<C-W><C-W>')
|
||||
@@ -583,17 +610,21 @@ mason_lspconfig.setup {
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
}
|
||||
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end,
|
||||
mason_lspconfig.setup {
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = servers[server_name],
|
||||
filetypes = (servers[server_name] or {}).filetypes,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
-- See `:help cmp`
|
||||
local cmp = require 'cmp'
|
||||
|
||||
Reference in New Issue
Block a user