Skip to content

Commit

Permalink
🔥 [add] Added hot settings
Browse files Browse the repository at this point in the history
  • Loading branch information
doremire committed Sep 17, 2023
1 parent 826e64e commit fba0d7c
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 94 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,3 @@ It's the coolest theme!!!
**あとは楽しんで!**
<br>
-- **Happy Coding!** 🚀 --

12 changes: 0 additions & 12 deletions after/plugin/barbar.lua

This file was deleted.

24 changes: 24 additions & 0 deletions after/plugin/bufferline.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require'bufferline'.setup()

local map = vim.api.nvim_set_keymap
local opts = {
noremap = true,
silent = true
}

-- 新しいバッファを作成して移動 (<C-n>)
map('n', '<C-m>', '<Cmd>enew<CR>', opts)
map('n', '<C-j>', '<Cmd>BufferLineCyclePrev<CR>', opts)
map('n', '<C-k>', '<Cmd> BufferLineCycleNext<CR>', opts)
map('n', '<leader>e', '<Cmd>bd<CR>', opts)

-- Ctrl+s で保存
map('n', '<C-l>', ':w<CR>', opts)
-- Ctrl+z で取り消し (undo)
map('n', '<C-z>', ':undo<CR>', opts)
-- Ctrl+y でやり直し (redo)
map('n', '<C-y>', ':redo<CR>', opts)




9 changes: 9 additions & 0 deletions after/plugin/colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ function ColorMyPencils(color)
-- vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
-- vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })

vim.cmd([[
hi NonText guifg=#444444
hi Whitespace guifg=#444444
hi IndentBlanklineChar guifg=#444444
hi IndentBlanklineContextChar guifg=#6d6d6d
hi IndentBlanklineSpaceChar guifg=#444444
hi IndentBlanklineSpaceCharBlankline guifg=#6d6d6d
]])

end

ColorMyPencils()
26 changes: 26 additions & 0 deletions after/plugin/headlines.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Aura Themeのカラーコード(例として以下のカラーコードを使用)
local aura_bg1 = "#282c34" -- これは例です。実際のカラーコードに置き換えてください。
local aura_bg2 = "#3a3f4b" -- これも例です。

vim.cmd("highlight Headline1 guibg=" .. aura_bg1)
vim.cmd("highlight Headline2 guibg=" .. aura_bg2)
vim.cmd("highlight CodeBlock guibg=" .. aura_bg1)
vim.cmd("highlight Dash guibg=" .. aura_bg1 .. " gui=bold")
vim.cmd("highlight Quote guibg=" .. aura_bg1)

require("headlines").setup {
markdown = {
headline_highlights = { "Headline1", "Headline2" },
codeblock_highlight = "CodeBlock",
dash_highlight = "Dash",
quote_highlight = "Quote",
},
org = {
headline_highlights = { "Headline1", "Headline2" },
codeblock_highlight = "CodeBlock",
dash_highlight = "Dash",
quote_highlight = "Quote",
},
-- 他のファイルタイプも同様に設定してください。
}

84 changes: 55 additions & 29 deletions after/plugin/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@ local lsp = require("lsp-zero")

lsp.preset("recommended")

lsp.ensure_installed({
'tsserver', -- TypeScript/JavaScript
'rust_analyzer', -- Rust
'gopls', -- Go
'pyright', -- Python
'lua_ls', -- Lua
'clangd', -- C/C++
'jdtls', -- Java
'html', -- HTML
'cssls', -- CSS
'jsonls', -- JSON
lsp.ensure_installed({'tsserver', -- TypeScript/JavaScript
'rust_analyzer', -- Rust
'gopls', -- Go
'pyright', -- Python
'lua_ls', -- Lua
'clangd', -- C/C++
'jdtls', -- Java
'html', -- HTML
'cssls', -- CSS
'jsonls', -- JSON
'marksman', -- Markdown
})

-- Fix Undefined global 'vim'
lsp.nvim_workspace()


local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_select = {
behavior = cmp.SelectBehavior.Select
}
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<C-y>'] = cmp.mapping.confirm({
select = true
}),
["<C-Space>"] = cmp.mapping.complete()
})

cmp_mappings['<Tab>'] = nil
cmp_mappings['<S-Tab>'] = nil

lsp.setup_nvim_cmp({
mapping = cmp_mappings
mapping = cmp_mappings
})

lsp.set_preferences({
Expand All @@ -46,18 +49,41 @@ lsp.set_preferences({
})

lsp.on_attach(function(client, bufnr)
local opts = {buffer = bufnr, remap = false}
local opts = {
buffer = bufnr,
remap = false
}

vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>vd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts)
vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
vim.keymap.set("n", "gd", function()
vim.lsp.buf.definition()
end, opts)
vim.keymap.set("n", "K", function()
vim.lsp.buf.hover()
end, opts)
vim.keymap.set("n", "<leader>vws", function()
vim.lsp.buf.workspace_symbol()
end, opts)
vim.keymap.set("n", "<leader>vd", function()
vim.diagnostic.open_float()
end, opts)
vim.keymap.set("n", "[d", function()
vim.diagnostic.goto_next()
end, opts)
vim.keymap.set("n", "]d", function()
vim.diagnostic.goto_prev()
end, opts)
vim.keymap.set("n", "<leader>vca", function()
vim.lsp.buf.code_action()
end, opts)
vim.keymap.set("n", "<leader>vrr", function()
vim.lsp.buf.references()
end, opts)
vim.keymap.set("n", "<leader>vrn", function()
vim.lsp.buf.rename()
end, opts)
vim.keymap.set("i", "<C-h>", function()
vim.lsp.buf.signature_help()
end, opts)
end)

lsp.setup()
Expand Down
125 changes: 93 additions & 32 deletions after/plugin/lualine.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
-- カスタムテーマの設定
-- カスタム色設定
local custom_colors = {
normal = {
a = {
bg = '#a277ff',
fg = '#1f1a27'
}, -- 入力モード
},
b = {
bg = '#1f1a27',
fg = '#adacae'
Expand All @@ -16,46 +16,107 @@ local custom_colors = {
}
}

-- lualineの設定
-- Lualine コンポーネントのためのヘルパー関数
local function location()
return string.format("行%d、列%d", vim.fn.line('.'), vim.fn.col('.'))
end

local function spaces()
return string.format("スペース:%s", vim.api.nvim_get_option('shiftwidth'))
end

local function get_encoding()
local encoding = vim.api.nvim_get_option('encoding')
return encoding == 'utf-8' and 'UTF-8' or encoding:upper()
end

local function get_fileformat()
local formats = {
unix = "LF",
dos = "CRLF"
}
return formats[vim.api.nvim_buf_get_option(0, 'fileformat')] or vim.api.nvim_buf_get_option(0, 'fileformat'):upper()
end

-- Git情報の設定
local last_git_info, last_update_time = "", 0
local update_interval = 10

local function translate_time(time)
local replacements = {
["second[s]* ago"] = "秒前",
["minute[s]* ago"] = "分前",
["hour[s]* ago"] = "時間前",
["day[s]* ago"] = "日前",
["week[s]* ago"] = "週間前",
["month[s]* ago"] = "ヶ月前",
["year[s]* ago"] = "年前"
}

for eng, jpn in pairs(replacements) do
time = time:gsub("(%d+) " .. eng, "%1" .. jpn)
end

return time
end

-- Gitの最終コミット情報を日本語で取得
local function git_info_japanese()
-- リポジトリの存在確認
local handle = io.popen('git rev-parse --is-inside-work-tree 2>&1')
local result = handle:read('*a')
handle:close()
if result:match('not a git repository') then
return ''
end

if os.time() - last_update_time > update_interval then
local name = vim.fn.system("git log -1 --pretty='%an'")
local time = translate_time(vim.fn.system("git log -1 --pretty='%ar'"))
last_git_info = string.format(" %s,%s", vim.fn.trim(name), vim.fn.trim(time))
last_update_time = os.time()
end
return last_git_info
end

-- カスタムブランチ情報を取得
local function custom_branch()
-- リポジトリの存在確認
local handle = io.popen('git rev-parse --is-inside-work-tree 2>&1')
local result = handle:read('*a')
handle:close()
if result:match('not a git repository') then
return ' Not a git repository'
end

handle = io.popen('git rev-parse --abbrev-ref HEAD 2> /dev/null')
local branch_name = handle:read("*a")
handle:close()
branch_name = branch_name:gsub("\n", "") -- 改行を削除

if branch_name == "" or branch_name == "HEAD" then
return ""
else
return "" .. branch_name .. "* "
end
end

-- Lualineの設定
require'lualine'.setup {
options = {
theme = custom_colors,
section_separators = {'', ''},
component_separators = {'', ''}
},
sections = {
-- 左側の設定
lualine_a = {'mode'},
lualine_b = {'branch'},
lualine_b = {custom_branch},
lualine_c = {{
'diagnostics',
sources = {'nvim_lsp'}
}, 'progress'},
-- 右側の設定
lualine_x = {function()
local line = vim.fn.line('.')
local col = vim.fn.col('.')
return string.format("行 %d、列 %d", line, col)
end, function()
local sw = vim.api.nvim_get_option('shiftwidth')
return string.format("スペース: %s", sw)
end, function()
local encoding = vim.api.nvim_get_option('encoding')
if encoding == 'utf-8' then
return 'UTF-8'
else
return encoding:upper()
end
end, function()
local ff = vim.api.nvim_buf_get_option(0, 'fileformat')
if ff == "unix" then
return "LF"
elseif ff == "dos" then
return "CRLF"
else
return ff:upper()
end
end, 'filetype'},
sources = {'nvim_lsp'},
sections = {'error', 'warn', 'info', 'hint'}
}},
lualine_x = {git_info_japanese, location, spaces, get_encoding, get_fileformat, 'filetype'},
lualine_y = {},
lualine_z = {}
}
Expand Down
25 changes: 20 additions & 5 deletions after/plugin/neo-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ local opts = {
noremap = true,
silent = true
}
local term_opts = {
silent = true
}
local keymap = vim.keymap.set
vim.api.nvim_set_keymap("n", "<C-b>", ":Neotree toggle<CR>", opts)

-- NeoTreeの設定
require('neo-tree').setup({
window = {
position = "left",
width = 25
},

})

vim.cmd [[
if argc() > 0
au VimEnter * Neotree toggle
au VimEnter * Neotree toggle
endif
highlight NeoTreeNormal guibg=#1b1b1b
highlight NeoTreeNormalNC guibg=#1b1b1b
]]

keymap("n", "<C-b>", ":Neotree toggle<Return>", opts)
Loading

0 comments on commit fba0d7c

Please sign in to comment.